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
33 .\" $FreeBSD: src/lib/libc/sys/rename.2,v 1.8.2.7 2001/12/14 18:34:01 ru Exp $
34 .\" $DragonFly: src/lib/libc/sys/rename.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
41 .Nd change the name of a file
47 .Fn rename "const char *from" "const char *to"
56 exists, it is first removed.
61 must be of the same type (that is, both directories or both
62 non-directories), and must reside on the same file system.
67 already exists, an instance of
69 will always exist, even if the system should crash in
70 the middle of the operation.
72 If the final component of
75 the symbolic link is renamed,
76 not the file or directory to which it points.
78 .\"The system can deadlock if a loop in the file system graph is present.
79 .\"This loop takes the form of an entry in directory
83 .\"being a hard link to directory
93 .\"When such a loop exists and two separate processes attempt to
95 .\".Ql rename a/foo b/bar
97 .\".Ql rename b/bar a/foo ,
99 .\"the system may deadlock attempting to lock
100 .\"both directories for modification.
101 .\"Hard links to directories should be
102 .\"replaced by symbolic links by the system administrator.
107 will fail and neither of the argument files will be
110 .It Bq Er ENAMETOOLONG
111 A component of either pathname exceeded 255 characters,
112 or the entire length of either path name exceeded 1023 characters.
121 A component of either path prefix denies search permission.
123 The requested link requires writing in a directory with a mode
124 that denies write permission.
126 The directory containing
129 and neither the containing directory nor
131 are owned by the effective user ID.
136 the directory containing
139 and neither the containing directory nor
141 are owned by the effective user ID.
143 Too many symbolic links were encountered in translating either pathname.
145 A component of either path prefix is not a directory.
159 and the file named by
161 are on different logical devices (file systems). Note that this error
162 code will not be returned if the implementation permits cross-device
165 The directory in which the entry for the new name is being placed
166 cannot be extended because there is no space left on the file
167 system containing the directory.
169 The directory in which the entry for the new name
170 is being placed cannot be extended because the
171 user's quota of disk blocks on the file system
172 containing the directory has been exhausted.
174 An I/O error occurred while making or updating a directory entry.
176 The requested link requires writing in a directory on a read-only file
180 points outside the process's allocated address space.
183 is a parent directory of
185 or an attempt is made to rename
191 is a directory and is not empty.
199 function call is expected to conform to