Question: I can use the RNFR
and
RNTO
commands to move a file, even across different
disks/mount points. And I can use RNFR
/RNTO
to move
a directory, but I cannot move a directory across different
disks/mount points. Is this a bug?
Answer: No, it is not a bug. Why not? Ultimately,
it is because the FTP specifications do not guarantee (or even discuss)
that an FTP implementation must support renaming of directories across
mount points.
ProFTPD implements the RNFR
/RNTO
functionality
by using the rename(2)
system call. And rename(2)
is documented to not work across mount points.
"But then why does it work when I rename a file across mount points?" you
ask. Good question. The answer is that for files only, ProFTPD
detects the rename(2)
error for renaming across mount points,
and then copies the file in question to the new location, deleting
the old location when the copy completes successfully.
"Great!" you say, "Now do the same thing for directories!" Unfortunately, for
directories, the answer is not that simple. Here are some things to consider
when copying directories: what if the directory contains sockets, FIFOs,
devices, and other irregular file types which cannot be easily copied/moved?
Should copying/moving of directories automatically use root privileges in
order to preserve the ownership on files that do not belong to the logged-in
user? What if the copying/deleting of files fails in the midde: what should
then happen to the copied (and remaining) files/directories?
Since there are no easy answers as yet to the above questions, ProFTPD now
detects the rename(2)
error for renaming across mount points
for a directory, and rejects the RNTO
command, showing
something like:
RNFR directory
350 File or directory exists, ready for destination name
RNTO /other/mount/directory
550 Rename /other/mount/directory: Is a directory
That "Is a directory" error indicates that ProFTPD cannot rename a directory
across the mount points you requested. (That particular error message can,
and will, be made more informative.)
© Copyright 2000-2022 The ProFTPD Project
All Rights Reserved