Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > R


HP-UX 11i Version 3: February 2007

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index


rename — change the name of a file


#include <stdio.h>

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


The rename() system call causes the source file to be renamed to target. If target exists, it is first removed. Both source and target must be of the same type (that is, either directories or nondirectories), 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.


rename() returns the following values:


Successful completion.


Failure. Neither file is affected. errno is set to indicate the error.


If rename() fails, errno is set to one of the following values.


A component of either path prefix denies search permission.


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


target or source is an existing directory that is the mount point for a mounted file system.


User's disk quota block or inode limit has been reached for this file system.


target is a directory and is not empty.


source or target points outside the allocated address space of the process. Reliable detection of this error is implementation dependent.


source is a parent directory of target, or an attempt is made to rename the . or .. directory.


target is a directory, but source is not.


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


A component of either path name exceeds NAME_MAX bytes while _POSIX_NO_TRUNC is in effect, or the entire length of either path name exceeds PATH_MAX bytes.


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


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


A component of either path prefix is not a directory.


source is a directory, but target is not.


The directory containing source has the sticky bit set, and neither the containing directory nor the source are owned by the effective user ID.


The target file exists, the directory containing target has the sticky bit set, and neither the containing directory nor the target are owned by the effective user ID.


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


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


rename() was developed by the University of California, Berkeley.




rename(): AES, SVID3, XPG3, XPG4, FIPS 151-2, POSIX.1, ANSI C

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.