Moving files between different drives (smbd/vfs-wrap.c)
Uli Gruber
uli.2001 at gmx.de
Tue Jun 26 23:43:57 GMT 2001
Hi,
> > In this subroutine, "result = rename(old, new);" is used to rename
files.
> > "rename" works fine on the save drive, but fails when "old" and "new"
are on
> > different drives. Is this a bug?
> >
> > Does anybody have an idea how to fix this?
>
> This is a problem with the way that rename(2) works. Certain versions of
> mv(1) are capable of doing the copy followed by a remove. A while back I
> asked on this list whether there was any reason not to do that within the
> VFS code and there was no negative response. See
> http://lists.samba.org/pipermail/samba-technical/2001-May/012916.html for
> details.
With 3 lines of code [taken from samba-2.0.7 - lib/doscalls.c - int
dos_rename(char *from, char *to)], the problem seems to be corrected:
samba-2.2.0-rename.dif
-----------------------------------
diff -uNr samba-2.2.0/source/smbd/vfs-wrap.c
samba-2.2.0-rename/source/smbd/vfs-wrap.c
--- samba-2.2.0/source/smbd/vfs-wrap.c Sat Apr 14 01:24:46 2001
+++ samba-2.2.0-rename/source/smbd/vfs-wrap.c Wed Jun 27 01:18:42 2001
@@ -248,6 +248,12 @@
#endif
result = rename(old, new);
+ if (errno == EXDEV)
+ {
+ /* Rename across filesystems needed. */
+ result = copy_reg(old, new);
+ }
+
END_PROFILE(syscall_rename);
return result;
}
-----------------------------------
Or are there any reasons why this could be a bad solution?
Uli
More information about the samba-technical
mailing list