Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ rename(2) — HP-UX 6.00

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

open(2)

RENAME(2)  —  HP-UX

Series 300 Only

NAME

rename − change the name of a file

SYNOPSIS

rename(source, target)
char *source, *target;

DESCRIPTION

Rename causes the file named source to be renamed target. If target exists, it is first removed.  Both source and target must be of the same type (that is, either directories or non-directories), and must reside on the same file system. 

If target can be created or if it existed before the call, rename guarantees that an instance of target will exist, even if the system crashes in the midst of the operation. 

If the final component of source is a symbolic link, the symbolic link is renamed, not the file or directory to which the symbolic link points. 

RETURN VALUE

If the operation succeeds, 0 is returned. If not, rename returns −1 and the global variable errno indicates the reason for the failure. 

ERRORS

Rename will fail and neither file will be affected if any of the following is true:

[EACCES] A component of either path prefix denies search permission. 

[EACCES] The requested link requires writing to a directory without write permission. 

[EBUSY] Target is an existing directory that is the mount point for a mounted file system. 

[EFAULT] Path points outside the allocated address space of the process.  The reliable detection of this error will be implementation dependent. 

[EINVAL] Source is a parent directory of target, or an attempt is made to rename “.” or “..”.

[EIO] An I/O error occurred while making or updating a directory entry. 

[EISDIR] Target is a directory, but source is not. 

[ELOOP] Too many symbolic links were encountered in translating either path name. 

[ENAMETOOLONG] A component of either path name exceeded MAXNAMLEN characters, or the entire length of either path name exceeded MAXPATHLEN−1 characters. 

[ENOENT] A component of the source path does not exist, or a path prefix of target does not exist. 

[ENOSPC] The destination directory cannot be extended, because of a lack of space on the file system containing the directory. 

[ENOTDIR] A component of either path prefix is not a directory. 

[ENOTDIR] Source is a directory, but target is not. 

[ENOTEMPTY] Target is a directory and is not empty. 

[EROFS] The requested link requires writing in a directory on a read-only file system. 

[EXDEV] The paths named by source and target are on different logical devices (file systems). 

WARNINGS

The system can deadlock if a loop in the file system graph is present.  For example, this loop might take the form of entry a/foo being a hard link to entry b/bar, while entry b/bar is hard linked to directory a.  When such a loop exists and two separate processes attempt to rename a/foo to b/bar and b/bar to a/foo, respectively, the system can deadlock while attempting to lock both directories for modification.  The system administrator should replace hard links to directories with symbolic links, if the system supports symbolic links (see symlink(4)).

AUTHOR

Rename was developed by the University of California, Berkeley California, Computer Science Division, Department of Electrical Engineering and Computer Science. 

SEE ALSO

open(2). 

Hewlett-Packard Company  —  Version B.1,  May 11, 2021

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026