*** UNIX MANUAL PAGE BROWSER ***

A Nergahak database for man pages research.

Navigation

Directory Browser

1Browse 4.4BSD4.4BSD
1Browse Digital UNIXDigital UNIX 4.0e
1Browse FreeBSDFreeBSD 14.3
1Browse MINIXMINIX 3.4.0rc6-d5e4fc0
1Browse NetBSDNetBSD 10.1
1Browse OpenBSDOpenBSD 7.7
1Browse UNIX v7Version 7 UNIX
1Browse UNIX v10Version 10 UNIX

Manual Page Search

Manual Page Result

0 Command: rename | Section: 2 | Source: Digital UNIX | File: rename.2.gz
rename(2) System Calls Manual rename(2) NAME rename - Renames a directory or a file within a file system SYNOPSIS #include <stdio.h> int rename ( const char *from, const char *to ); [Digital] The following definition of the rename() function does not conform to current standards and is supported only for backward compat- ibility (see standards(5)): int rename ( char *from, char *to ); STANDARDS Interfaces documented on this reference page conform to industry stan- dards as follows: rename(): POSIX.1, XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about in- dustry standards and associated tags. PARAMETERS Identifies the file or directory to be renamed. Identifies the new pathname of the file or directory to be renamed. If the to parameter is an existing file or empty directory, it is replaced by the from parame- ter. If the to parameter is a nonempty directory, the rename() function exits with an error. DESCRIPTION The rename() function renames a directory or a file within a file sys- tem. For rename() to complete successfully, the calling process must have write and search permission to the parent directories of both the from and to parameters. If the from parameter is a directory and the parent directories of from and to are different, then the calling process must have write and search permission to the from parameter as well. If the from and to parameters both refer to the same existing file, the rename() function returns successfully and performs no other action. Both the from and to parameters must be of the same type (that is, both directories or both nondirectories) and must reside on the same file system. If the to parameter already exists, it is first removed. In this case it is guaranteed that a link named the to parameter will ex- ist throughout the operation. This link refers to the file named by ei- ther the to or from parameter before the operation began. If the final component of the from parameter is a symbolic link, the symbolic link (not the file or directory to which it points) is re- named. If the final component of the to parameter is a symbolic link, the symbolic link is destroyed. If the from and to parameters name directories, the following must be true: The from parameter is not an ancestor of the to parameter. For example, the to pathname must not contain a path prefix that names from. The from parameter is well-formed. For example, the . (dot) en- try in from, if it exists, refers to the same directory as from, ex- actly one directory has a link to from (excluding the self-referential . ), and the .. (dot-dot) entry in from, if it exists, refers to the directory that contains an entry for from. The to parameter, if it ex- ists, must be well-formed (as defined previously). Upon successful completion, the rename() function marks the st_ctime and st_mtime fields of the parent directory of each file for update. RETURN VALUES Upon successful completion, the rename() function returns a value of 0 (zero). Otherwise, a value of -1 is returned, and errno is set to in- dicate the error. ERRORS If the rename() function fails, the file or directory name remains un- changed and errno may be set to one of the following values: Creating the requested link requires writing in a directory with a mode that de- nies write permission, or a component of either pathname denies search permission. The directory named by the from or to parameter is cur- rently in use by the system or by another process. The directory that would contain to cannot be extended because the user's quota of disk blocks on the file system containing the directory is exhausted. The to parameter is an existing nonempty directory. Either the to or from parameter is an invalid address. Either the from or to parameter is not a well-formed directory, an attempt is made to rename . (dot) or .. (dot-dot), or the from parameter is an ancestor of the to parameter. The to parameter names a directory and the from parameter names a nondirectory. Too many links were encountered in translating either to or from. The length of the to or from parameters exceeds PATH_MAX or a pathname component is longer than NAME_MAX. Indicates either that the system file table is full, or that there are too many files currently open in the system. A component of either path does not exist, or ei- ther path is the empty string, or the file named by the from parameter does not exist. The directory that would contain to cannot be extended because the file system is out of space. The from parameter names a directory and the to parameter names a nondirectory. The S_ISVTX flag is set on the directory containing the file to be renamed, and the caller is not the file owner. The requested operation requires writing in a directory on a read-only file system. The link named by the to parameter and the file named by the from parameter are on different file systems. RELATED INFORMATION Functions: chmod(2), link(2), mkdir(2), rmdir(2), unlink(2) Commands: chmod(1), mkdir(1), mv(1), mvdir(1) Standards: standards(5) delim off rename(2)

Navigation Options