Requirements Catalog of LSB Core 3.1
Requirements for the function 'rename'
| Standard | ID | Description |
| SUSv3 | rename.01 | The rename() function shall change the name of a file |
| SUSv3 | rename.02 | If either the old or new argument names a symbolic link, rename() shall operate on the symbolic link itself, and shall not resolve the last component of the argument. |
| SUSv3 | rename.03 | If the old argument and the new argument resolve to the same existing file, rename() shall return successfully and perform no other action |
| SUSv3 | rename.04 | If the old argument points to the pathname of a file that is not a directory, the new argument shall not point to the pathname of a directory |
| SUSv3 | rename.05 | If the link named by the new argument exists, it shall be removed and old renamed to new |
| SUSv3 | rename.06 | In this case, a link named new shall remain visible to other processes throughout the renaming operation and refer either to the file referred to by new or old before the operation began |
| SUSv3 | rename.07 | Write access permission is required for both the directory containing old and the directory containing new |
| SUSv3 | rename.08 | If the old argument points to the pathname of a directory, the new argument shall not point to the pathname of a file that is not a directory |
| SUSv3 | rename.09 | If the directory named by the new argument exists, it shall be removed and old renamed to new. |
| SUSv3 | rename.23 | In this case, a link named new shall exist throughout the renaming operation and shall refer either to the directory referred to by new or old before the operation began |
| SUSv3 | rename.10 | If new names an existing directory, it shall be required to be an empty directory. |
| SUSv3 | rename.11 | If the old argument points to a pathname of a symbolic link, the symbolic link shall be renamed |
| SUSv3 | rename.12 | If the new argument points to a pathname of a symbolic link, the symbolic link shall be removed |
| SUSv3 | rename.13 | The new pathname shall not contain a path prefix that names old |
| SUSv3 | rename.14 | Write access permission is required for the directory containing old and the directory containing new |
| SUSv3 | rename.15 | If the old argument points to the pathname of a directory, write access permission may be required for the directory named by old |
| SUSv3 | rename.16 | and, if it exists, the directory named by new. |
| SUSv3 | rename.17 | If the link named by the new argument exists and the file's link count becomes 0 when it is removed and no process has the file open, the space occupied by the file shall be freed and the file shall no longer be accessible |
| SUSv3 | rename.18 | If one or more processes have the file open when the last link is removed, the link shall be removed before rename() returns, but the removal of the file contents shall be postponed until all references to the file are closed |
| SUSv3 | rename.19 | Upon successful completion, rename() shall mark for update the st_ctime and st_mtime fields of the parent directory of each file |
| SUSv3 | rename.20 | If the rename() function fails for any reason other than [EIO], any file named by new shall be unaffected |
| SUSv3 | rename.21 | Upon successful completion, rename() shall return 0; |
| SUSv3 | rename.22 | otherwise, -1 shall be returned, [CX] errno shall be set to indicate the error, |
| SUSv3 | rename.24 | and neither the file named by old nor the file named by new shall be changed or created |
| SUSv3 | rename.90 | The rename() function shall fail if: |
| SUSv3 | rename.90.01 | [EACCES] [CX] A component of either path prefix denies search permission; or one of the directories containing old or new denies write permissions; or, write permission is required and is denied for a directory pointed to by the old or new arguments. |
| SUSv3 | rename.90.02 | [EBUSY] [CX] The directory named by old or new is currently in use by the system or another process, and the implementation considers this an error. |
| SUSv3 | rename.90.03 | [EEXIST] or [ENOTEMPTY] [CX] The link named by new is a directory that is not an empty directory. |
| SUSv3 | rename.90.04 | [EINVAL] [CX] The new directory pathname contains a path prefix that names the old directory. |
| SUSv3 | rename.90.05 | [EIO] [CX] A physical I/O error has occurred. |
| SUSv3 | rename.90.06 | [EISDIR] [CX] The new argument points to a directory and the old argument points to a file that is not a directory. |
| SUSv3 | rename.90.07 | [ELOOP] [CX] A loop exists in symbolic links encountered during resolution of the path argument. |
| SUSv3 | rename.90.08 | [EMLINK] [CX] The file named by old is a directory, and the link count of the parent directory of new would exceed {LINK_MAX}. |
| SUSv3 | rename.90.09 | [ENAMETOOLONG] [CX] The length of the old or new argument exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. |
| SUSv3 | rename.90.10 | [ENOENT] [CX] The link named by old does not name an existing file, or either old or new points to an empty string. |
| SUSv3 | rename.90.11 | [ENOSPC] [CX] The directory that would contain new cannot be extended. |
| SUSv3 | rename.90.12 | [ENOTDIR] [CX] A component of either path prefix is not a directory; or the old argument names a directory and new argument names a non-directory file. |
| SUSv3 | rename.90.13 | [EPERM] or [EACCES] [XSI] The S_ISVTX flag is set on the directory containing the file referred to by old and the caller is not the file owner, nor is the caller the directory owner, nor does the caller have appropriate privileges; or new refers to an existing file, the S_ISVTX flag is set on the directory containing this file, and the caller is not the file owner, nor is the caller the directory owner, nor does the caller have appropriate privileges. |
| SUSv3 | rename.90.14 | [EROFS] [CX] The requested operation requires writing in a directory on a read-only file system. |
| SUSv3 | rename.90.15 | [EXDEV] [CX] The links named by new and old are on different file systems and the implementation does not support links between file systems. |
| SUSv3 | rename.91 | The rename() function may fail if: |
| SUSv3 | rename.91.01 | [EBUSY] [XSI] The file named by the old or new arguments is a named STREAM. |
| SUSv3 | rename.91.02 | [ELOOP] [CX] More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the path argument. |
| SUSv3 | rename.91.03 | [ENAMETOOLONG] [CX] As a result of encountering a symbolic link in resolution of the path argument, the length of the substituted pathname string exceeded {PATH_MAX}. |
| SUSv3 | rename.91.04 | [ETXTBSY] [CX] The file to be renamed is a pure procedure (shared text) file that is being executed. |