Re: Using rename() across file systems
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Fri, 26 Oct 2007 13:01:46 +0200
JH Trauntvein <j.trauntvein@xxxxxxxxxxx> writes:
I am working on an application that can transfer a file over a
potentially slow link and, when the transfer has successfully
completed, copies the file from a temporary file that was created for
this purpose to its final destination. I am using the rename()
function to do this final step. I have read in "Advanced Unix
Programming" by Marc Rochkind that rename will not work if the source
and destination reside on different file systems. The man page for
rename(), however, is silent on the matter of different file systems
and Mr. Rochkind's remarks seem almost parenthetical. I would like to
confirm that the limitation actually exists.
This is implemenation defined, as of UNIX(*), cf
[EXDEV]
[CX] [Option Start] The links named by new and old are on
different file systems and the implementation does not support
links between file systems. [Option End]
(SUS, 'rename')
If this limitation actually does exist, my intention is to have my own
function detect this by calling statvfs() for the source name and the
name of the parent in the destination and comparing the f_fsid member
of the resulting structures. If this value is different, i assume
that the file systems are different and I will have to do a copy
operation instead. Is this assumption correct?
This would again depend on the implementation, namely, on what exactly
constitutes a 'file system id'. I suggest a simpler method: Try to
rename and if this fails with EXDEV, copy.
.
- Follow-Ups:
- Re: Using rename() across file systems
- From: Jon
- Re: Using rename() across file systems
- References:
- Using rename() across file systems
- From: JH Trauntvein
- Using rename() across file systems
- Prev by Date: Re: Using rename() across file systems
- Next by Date: see the riboosomes pics and information
- Previous by thread: Re: Using rename() across file systems
- Next by thread: Re: Using rename() across file systems
- Index(es):
Relevant Pages
|