1 .\" Copyright (c) 1983, 1991, 1993
2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. All advertising materials mentioning features or use of this software
13 .\" must display the following acknowledgement:
14 .\" This product includes software developed by the University of
15 .\" California, Berkeley and its contributors.
16 .\" 4. Neither the name of the University nor the names of its contributors
17 .\" may be used to endorse or promote products derived from this software
18 .\" without specific prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 .\" @(#)rename.2 8.1 (Berkeley) 6/4/93
40 .Nd change the name of a file
42 .Fd #include <stdio.h>
44 .Fn rename "const char *from" "const char *to"
53 exists, it is first removed.
58 must be of the same type (that is, both directories or both
59 non-directories), and must reside on the same file system.
62 guarantees that an instance of
64 will always exist, even if the system should crash in
65 the middle of the operation.
67 If the final component of
70 the symbolic link is renamed,
71 not the file or directory to which it points.
73 .\"The system can deadlock if a loop in the file system graph is present.
74 .\"This loop takes the form of an entry in directory
78 .\"being a hard link to directory
88 .\"When such a loop exists and two separate processes attempt to
90 .\".Ql rename a/foo b/bar
92 .\".Ql rename b/bar a/foo ,
94 .\"the system may deadlock attempting to lock
95 .\"both directories for modification.
96 .\"Hard links to directories should be
97 .\"replaced by symbolic links by the system administrator.
99 A 0 value is returned if the operation succeeds, otherwise
101 returns -1 and the global variable
103 indicates the reason for the failure.
106 will fail and neither of the argument files will be
108 .Bl -tag -width ENAMETOOLONG
109 .It Bq Er ENAMETOOLONG
110 A component of either pathname exceeded 255 characters,
111 or the entire length of either path name exceeded 1023 characters.
120 A component of either path prefix denies search permission.
122 The requested link requires writing in a directory with a mode
123 that denies write permission.
125 The directory containing
128 and neither the containing directory nor
130 are owned by the effective user ID.
135 the directory containing
138 and neither the containing directory nor
140 are owned by the effective user ID.
142 Too many symbolic links were encountered in translating either pathname.
144 A component of either path prefix is not a directory.
158 and the file named by
160 are on different logical devices (file systems). Note that this error
161 code will not be returned if the implementation permits cross-device
164 The directory in which the entry for the new name is being placed
165 cannot be extended because there is no space left on the file
166 system containing the directory.
168 The directory in which the entry for the new name
169 is being placed cannot be extended because the
170 user's quota of disk blocks on the file system
171 containing the directory has been exhausted.
173 An I/O error occurred while making or updating a directory entry.
175 The requested link requires writing in a directory on a read-only file
179 points outside the process's allocated address space.
182 is a parent directory of
184 or an attempt is made to rename
190 is a directory and is not empty.
198 function call is expected to conform to