home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
gnu
/
man
/
cat2
/
rename.0
< prev
next >
Wrap
Text File
|
1993-12-07
|
5KB
|
133 lines
RENAME(2) UNIX Programmer's Manual RENAME(2)
NNAAMMEE
rreennaammee - change the name of a file
SSYYNNOOPPSSIISS
##iinncclluuddee <<ssttddiioo..hh>>
_i_n_t
rreennaammee(_c_o_n_s_t _c_h_a_r _*_f_r_o_m, _c_o_n_s_t _c_h_a_r _*_t_o)
DDEESSCCRRIIPPTTIIOONN
RReennaammee() causes the link named _f_r_o_m to be renamed as _t_o. If _t_o exists, it
is first removed. Both _f_r_o_m and _t_o must be of the same type (that is,
both directories or both nondirectories), and must reside on the same
file system.
RReennaammee() guarantees that an instance of _t_o will always exist, even if the
system should crash in the middle of the operation.
If the final component of _f_r_o_m is a symbolic link, the symbolic link is
renamed, not the file or directory to which it points.
CCAAVVEEAATT
The system can deadlock if a loop in the file system graph is present.
This loop takes the form of an entry in directory `_a', say `_a_/_f_o_o', being
a hard link to directory `_b', and an entry in directory `_b', say `_b_/_b_a_r',
being a hard link to directory `_a'. When such a loop exists and two sepa
rate processes attempt to perform `rename a/foo b/bar' and `rename b/bar
a/foo', respectively, the system may deadlock attempting to lock both di
rectories for modification. Hard links to directories should be replaced
by symbolic links by the system administrator.
RREETTUURRNN VVAALLUUEESS
A 0 value is returned if the operation succeeds, otherwise rreennaammee() re
turns 1 and the global variable _e_r_r_n_o indicates the reason for the fail
ure.
EERRRROORRSS
RReennaammee() will fail and neither of the argument files will be affected if:
[EINVAL] Either pathname contains a character with the highorder
bit set.
[ENAMETOOLONG]
A component of either pathname exceeded 255 characters, or
the entire length of either path name exceeded 1023 charac
ters.
[ENOENT] A component of the _f_r_o_m path does not exist, or a path pre
fix of _t_o does not exist.
[EACCES] A component of either path prefix denies search permission.
[EACCES] The requested link requires writing in a directory with a
mode that denies write permission.
[EPERM] The directory containing _f_r_o_m is marked sticky, and neither
the containing directory nor _f_r_o_m are owned by the effec
tive user ID.
[EPERM] The _t_o file exists, the directory containing _t_o is marked
sticky, and neither the containing directory nor _t_o are
owned by the effective user ID.
[ELOOP] Too many symbolic links were encountered in translating ei
ther pathname.
[ENOTDIR] A component of either path prefix is not a directory.
[ENOTDIR] _f_r_o_m is a directory, but _t_o is not a directory.
[EISDIR] _t_o is a directory, but _f_r_o_m is not a directory.
[EXDEV] The link named by _t_o and the file named by _f_r_o_m are on dif
ferent logical devices (file systems). Note that this er
ror code will not be returned if the implementation permits
crossdevice links.
[ENOSPC] The directory in which the entry for the new name is being
placed cannot be extended because there is no space left on
the file system containing the directory.
[EDQUOT] The directory in which the entry for the new name is being
placed cannot be extended because the user's quota of disk
blocks on the file system containing the directory has been
exhausted.
[EIO] An I/O error occurred while making or updating a directory
entry.
[EROFS] The requested link requires writing in a directory on a
readonly file system.
[EFAULT] _P_a_t_h points outside the process's allocated address space.
[EINVAL] _F_r_o_m is a parent directory of _t_o, or an attempt is made to
rename `.' or `..'.
[ENOTEMPTY] _T_o is a directory and is not empty.
SSEEEE AALLSSOO
open(2)
SSTTAANNDDAARRDDSS
RReennaammee() conforms to IEEE Std 1003.11988 (``POSIX'').
4.2 Berkeley Distribution March 10, 1991 2