I run the following code:
mkdir('mnt/1',0777,true);
mkdir('mnt/a',0777);
Directory "a" is created, while directory "1" is not, page prints warning.
Warning: mkdir(): File exists in /home/bitrix/www/php_test.php on line 3
I have full permissions on directory mnt for user apache is running:
drwxr-xr-x 1 bitrix bitrix 4096 Nov 28 10:10 mnt
PHP version - PHP 5.3.3. Apache version 2.2.15.
Any ideas, why mkdir fails with recursive option set to true?
Update! Well I cleared the folder, made the following php-script and ran it again:
<?php
error_reporting(E_ALL);
mkdir('mnt/1',0777,true);
mkdir('mnt/2/',0777,true);
mkdir('./mnt/3',0777,true);
mkdir('./mnt/4/',0777,true);
mkdir('mnt/a',0777);
mkdir('mnt/b/',0777);
mkdir('./mnt/c',0777);
mkdir('./mnt/d/',0777);
?>
Here is the output:
Warning: mkdir(): File exists in /home/bitrix/www/php_test.php on line 3
Warning: mkdir(): File exists in /home/bitrix/www/php_test.php on line 4
Warning: mkdir(): File exists in /home/bitrix/www/php_test.php on line 5
Warning: mkdir(): File exists in /home/bitrix/www/php_test.php on line 6
Here is the content of the folder mnt after script execution:
drwxr-xr-x 1 bitrix bitrix 4096 Nov 28 2012 .
drwxrwx--- 11 bitrix bitrix 12288 Nov 28 11:10 ..
drwxr-xr-x 1 bitrix bitrix 0 Nov 28 2012 a
drwxr-xr-x 1 bitrix bitrix 0 Nov 28 2012 b
drwxr-xr-x 1 bitrix bitrix 0 Nov 28 2012 c
drwxr-xr-x 1 bitrix bitrix 0 Nov 28 2012 d
I also tried absolute path for recursive mkdir - still no luck, while non-recursive mkdir works fine no matter how the path is set. What's wrong with recursive mkdir? I still have no ideas..
Update! Further investigation revealed that such things happen because mnt is a folder, mounted by command
mount -t cifs -o username=***user***,password=***password***,uid=bitrix,gid=bitrix,iocharset=utf8,codepage=866 //192.168.1.6/folder /home/bitrix/www/mnt
In all other directories recursive mkdir works fine, while in that directory only non-recursive mkdir works!
Update! As femtoRgon assumed mkdir, when run from script in the folder mnt
, works fine both recursive and non-recursive. But still I can't figure out, why it fails, when run from /home/bitrix/www? I even tried mounting with options file_mode=0775,dir_mode=0775
- no luck. My OS = CentOS 6.3, if it matters..
After some googling, I found the answer on php.net. It is all about serverino
mount option. When I mounted folder with noserverino
all problems were gone. Anyway thanks guys for trying to help!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With