xref: /minix/minix/man/man2/rename.2 (revision 83133719)
Copyright (c) 1983 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)rename.2 6.4 (Berkeley) 5/22/86

RENAME 2 "May 22, 1986"
C 5
NAME
rename - change the name of a file
SYNOPSIS
#include <stdio.h>

int rename(const char *from, const char *to)
DESCRIPTION
Rename causes the link named from to be renamed as to . If to exists, then it is first removed. Both from and to must be of the same type (that is, both directories or both non-directories), and must reside on the same file system.

Rename guarantees that an instance of to will always exist, even if the system should crash in the middle of the operation.

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

"RETURN VALUE"
A 0 value is returned if the operation succeeds, otherwise rename returns -1 and the global variable errno indicates the reason for the failure.
"ERRORS
Rename will fail and neither of the argument files will be affected if any of the following are true:

15 [ENAMETOOLONG] A path name exceeds PATH_MAX characters.

15 [ENOENT] A component of the from path does not exist, or a path prefix of to does not exist.

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

15 [EACCES] The requested link requires writing in a directory with a mode that denies write permission.

15 [EPERM] The directory containing from is marked sticky, and neither the containing directory nor from are owned by the effective user ID.

15 [EPERM] The to file exists, the directory containing to is marked sticky, and neither the containing directory nor to are owned by the effective user ID.

15 [ELOOP] Too many symbolic links were encountered in translating either pathname. (Minix-vmd)

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

15 [ENOTDIR] From is a directory, but to is not a directory.

15 [EISDIR] To is a directory, but from is not a directory.

15 [EXDEV] The link named by to and the file named by from are on different logical devices (file systems).

15 [ENOSPC] The directory in which the entry for the new name is being placed cannot be extended because there is no space left on the file system containing the directory.

15 [EDQUOT] The directory in which the entry for the new name is being placed cannot be extended because the user's quota of disk blocks on the file system containing the directory has been exhausted. ..

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

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

15 [EFAULT] Path points outside the process's allocated address space.

15 [EINVAL] From is a parent directory of to , or an attempt is made to rename ``.'' or ``..''.

15 [ENOTEMPTY] To is a directory and is not empty.

"SEE ALSO"
open (2)