rename(3f)

Name
rename - changes the name of a file

Syntax
integer rename, err
character*len from, to
external rename
err = rename ( from, to )

Description
The rename function 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 file type (that is, both must be directories or both must not be directories), and must reside on the same file system.

The rename function guarantees that an instance of to always exists, even if the system should crash in the middle of the operation.

Restrictions
The system can deadlock if a loop in the file system graph is present. This loop takes the form of an entry in directory "a", for example "a/foo", being a hard link to directory "b", and an entry in directory "b", for example "b/bar", being a hard link to directory "a". When such a loop exists and two separate processes attempt to perform "rename a/foo b/bar" and "rename b/bar a/foo", respectively, the system may deadlock attempting to lock both directories for modification.

Return Values
If the rename function is successful, it returns a zero value; otherwise rename returns the error number.

See Also
open(2), rename(2)