1 .\" $NetBSD: rename.2,v 1.7 1995/02/27 12:36:15 cgd Exp $
3 .\" Copyright (c) 1983, 1991, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. All advertising materials mentioning features or use of this software
15 .\" must display the following acknowledgement:
16 .\" This product includes software developed by the University of
17 .\" California, Berkeley and its contributors.
18 .\" 4. Neither the name of the University nor the names of its contributors
19 .\" may be used to endorse or promote products derived from this software
20 .\" without specific prior written permission.
22 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 .\" @(#)rename.2 8.1 (Berkeley) 6/4/93
41 .Nd change the name of a file
43 .Fd #include <stdio.h>
45 .Fn rename "const char *from" "const char *to"
54 exists, it is first removed.
59 must be of the same type (that is, both directories or both
60 non-directories), and must reside on the same file system.
63 guarantees that an instance of
65 will always exist, even if the system should crash in
66 the middle of the operation.
68 If the final component of
71 the symbolic link is renamed,
72 not the file or directory to which it points.
74 The system can deadlock if a loop in the file system graph is present.
75 This loop takes the form of an entry in directory
79 being a hard link to directory
89 When such a loop exists and two separate processes attempt to
91 .Ql rename a/foo b/bar
93 .Ql rename b/bar a/foo ,
95 the system may deadlock attempting to lock
96 both directories for modification.
97 Hard links to directories should be
98 replaced by symbolic links by the system administrator.
100 A 0 value is returned if the operation succeeds, otherwise
102 returns -1 and the global variable
104 indicates the reason for the failure.
107 will fail and neither of the argument files will be
110 .It Bq Er ENAMETOOLONG
111 A component of a pathname exceeded
113 characters, or an entire path name exceeded
124 A component of either path prefix denies search permission.
126 The requested link requires writing in a directory with a mode
127 that denies write permission.
129 The directory containing
132 and neither the containing directory nor
134 are owned by the effective user ID.
139 the directory containing
142 and neither the containing directory nor
144 are owned by the effective user ID.
146 Too many symbolic links were encountered in translating either pathname.
148 A component of either path prefix is not a directory.
162 and the file named by
164 are on different logical devices (file systems). Note that this error
165 code will not be returned if the implementation permits cross-device
168 The directory in which the entry for the new name is being placed
169 cannot be extended because there is no space left on the file
170 system containing the directory.
172 The directory in which the entry for the new name
173 is being placed cannot be extended because the
174 user's quota of disk blocks on the file system
175 containing the directory has been exhausted.
177 An I/O error occurred while making or updating a directory entry.
179 The requested link requires writing in a directory on a read-only file
183 points outside the process's allocated address space.
186 is a parent directory of
188 or an attempt is made to rename
194 is a directory and is not empty.