1 .\" Copyright (c) 1983 Regents of the University of California.
2 .\" All rights reserved. The Berkeley software License Agreement
3 .\" specifies the terms and conditions for redistribution.
5 .\" @(#)rename.2 6.4 (Berkeley) 5/22/86
7 .TH RENAME 2 "May 22, 1986"
10 rename \- change the name of a file
16 int rename(const char *\fIfrom\fP, const char *\fIto\fP)
27 exists, then it is first removed.
32 must be of the same type (that is, both directories or both
33 non-directories), and must reside on the same file system.
36 guarantees that an instance of
38 will always exist, even if the system should crash in
39 the middle of the operation.
41 If the final component of
44 the symbolic link is renamed,
45 not the file or directory to which it points.
47 A 0 value is returned if the operation succeeds, otherwise
49 returns \-1 and the global variable
51 indicates the reason for the failure.
54 will fail and neither of the argument files will be
55 affected if any of the following are true:
58 A path name exceeds PATH_MAX characters.
61 A component of the \fIfrom\fP path does not exist,
62 or a path prefix of \fIto\fP does not exist.
65 A component of either path prefix denies search permission.
68 The requested link requires writing in a directory with a mode
69 that denies write permission.
72 The directory containing \fIfrom\fP is marked sticky,
73 and neither the containing directory nor \fIfrom\fP
74 are owned by the effective user ID.
77 The \fIto\fP file exists,
78 the directory containing \fIto\fP is marked sticky,
79 and neither the containing directory nor \fIto\fP
80 are owned by the effective user ID.
83 Too many symbolic links were encountered in translating either pathname.
87 A component of either path prefix is not a directory.
91 is a directory, but \fIto\fP is not a directory.
95 is a directory, but \fIfrom\fP is not a directory.
98 The link named by \fIto\fP and the file named by \fIfrom\fP
99 are on different logical devices (file systems).
102 The directory in which the entry for the new name is being placed
103 cannot be extended because there is no space left on the file
104 system containing the directory.
108 The directory in which the entry for the new name
109 is being placed cannot be extended because the
110 user's quota of disk blocks on the file system
111 containing the directory has been exhausted.
115 An I/O error occurred while making or updating a directory entry.
118 The requested link requires writing in a directory on a read-only file
123 points outside the process's allocated address space.
127 is a parent directory of
129 or an attempt is made to rename ``.'' or ``..''.
133 is a directory and is not empty.