Edit report at http://bugs.php.net/bug.php?id=50676&edit=1
ID: 50676 Comment by: sta at netimage dot dk Reported by: andreas at heigl dot org Summary: rename across Volumes throws warning "Operation not permitted" Status: Bogus Type: Bug Package: Filesystem function related Operating System: Mac OS X 10.6 PHP Version: 5.3.1 Block user comment: N New Comment: I would like to second the suggestion of ahar...@php.net about making this a Documentation issue. I just spend 2 ours trying to figure out why rename() started spitting out warnings and still returned true. It could be something like <blockquote> <p> <b class="note">Note</b>: <span class="simpara"> If $oldname and $newname are on different partitions (on *nix based systems) the function might emit a warning "Warning: rename(oldfil,newfile): Operation not permitted" and still succeed. The reason is that internally the rename is done by copying the file, and attempting chown() and chmod() on the new file - and these operations can fail. </span> </p> </blockquote> FreeBSD, Apache 2.2, PHP 5.3.3. Thanks for all the good work. /Søren Thing Previous Comments: ------------------------------------------------------------------------ [2010-01-14 15:21:34] ahar...@php.net The warnings may also be coming from the chown() and chmod() calls that occur between the copy and unlink when the rename call has to be faked across partitions -- there's no way of distinguishing them, since the warnings in php_plain_files_rename() just wrap strerror(). I wonder if this might be worth morphing into a doc bug: the rename manual page currently says that, as of 4.3.3, "rename() is now able to rename files across partitions on *nix based systems", which does seem to be overstating things a little. Something along the lines of "rename() may be able to rename files across partitions on *nix based systems, provided the appropriate permissions are held. Warnings may be thrown if the destination filesystem doesn't permit chown() or chmod() calls to be made on files." might be better. ------------------------------------------------------------------------ [2010-01-14 15:10:12] paj...@php.net Volumes can be mounted everywhere on windows as well. That does not change the fact that they are a different volume. Please read the underlying documentations for rename and how it works, that may help to understand the limitation. ------------------------------------------------------------------------ [2010-01-14 14:45:05] andreas at heigl dot org I understand, that rename can only operate on the same volume (like the move-command). But unlike in windows on a Mac (as on any other UNIX-like environment) volumes can be mount anywhere in the folder-hirachy, so that it is rather difficult to check whether source and target of the rename are on the same volume or not. And as I pointed out in the original bug-report, the source-file actually is deleted, so there is no need for the error message. ------------------------------------------------------------------------ [2010-01-14 13:56:49] il...@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php rename() can only work "normally" when operating on the same volume. In your case it emulates rename via copy & delete. I would guess since it cannot delete file from the original volume, it gives you an error message. ------------------------------------------------------------------------ [2010-01-11 12:59:23] p dot szalko at gmail dot com The same bug is in PHP 5.2.11 and Mac OS X 10.5 ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/bug.php?id=50676 -- Edit this bug report at http://bugs.php.net/bug.php?id=50676&edit=1