Files
oldlinux-files/Minix/2.0.0/wwwman/man2/rename.2.html
2024-02-19 00:21:39 -05:00

124 lines
3.8 KiB
HTML

<HTML>
<HEAD>
<TITLE>rename(2)</TITLE>
</HEAD>
<BODY>
<H1>rename(2)</H1>
<HR>
<PRE>
</PRE>
<H2>NAME</H2><PRE>
rename - change the name of a file
</PRE>
<H2>SYNOPSIS</H2><PRE>
<STRONG>#include</STRONG> <STRONG>&lt;stdio.h&gt;</STRONG>
<STRONG>int</STRONG> <STRONG>rename(const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>from</EM><STRONG>,</STRONG> <STRONG>const</STRONG> <STRONG>char</STRONG> <STRONG>*</STRONG><EM>to</EM><STRONG>)</STRONG>
</PRE>
<H2>DESCRIPTION</H2><PRE>
<STRONG>Rename</STRONG> causes the link named <EM>from</EM> to be renamed as <EM>to</EM>. If <EM>to</EM> exists,
then it is first removed. Both <EM>from</EM> and <EM>to</EM> must be of the same type
(that is, both directories or both non-directories), and must reside on
the same file system.
<STRONG>Rename</STRONG> guarantees that an instance of <EM>to</EM> will always exist, even if the
system should crash in the middle of the operation.
If the final component of <EM>from</EM> is a symbolic link, the symbolic link is
renamed, not the file or directory to which it points.
</PRE>
<H2>RETURN VALUE</H2><PRE>
A 0 value is returned if the operation succeeds, otherwise <STRONG>rename</STRONG> returns
-1 and the global variable <STRONG>errno</STRONG> indicates the reason for the failure.
</PRE>
<H2>ERRORS</H2><PRE>
<STRONG>Rename</STRONG> will fail and neither of the argument files will be affected if
any of the following are true:
[ENAMETOOLONG] A path name exceeds PATH_MAX characters.
[ENOENT] A component of the <EM>from</EM> path does not exist, or a path
prefix of <EM>to</EM> does not exist.
[EACCES] A component of either path prefix denies search
permission.
[EACCES] The requested link requires writing in a directory with a
mode that denies write permission.
[EPERM] The directory containing <EM>from</EM> is marked sticky, and
neither the containing directory nor <EM>from</EM> are owned by the
effective user ID.
[EPERM] The <EM>to</EM> file exists, the directory containing <EM>to</EM> is marked
sticky, and neither the containing directory nor <EM>to</EM> are
owned by the effective user ID.
[ELOOP] Too many symbolic links were encountered in translating
either pathname. (Minix-vmd)
[ENOTDIR] A component of either path prefix is not a directory.
[ENOTDIR] <EM>From</EM> is a directory, but <EM>to</EM> is not a directory.
[EISDIR] <EM>To</EM> is a directory, but <EM>from</EM> is not a directory.
[EXDEV] The link named by <EM>to</EM> and the file named by <EM>from</EM> are on
different logical devices (file systems).
[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.
[EIO] An I/O error occurred while making or updating a directory
entry.
[EROFS] The requested link requires writing in a directory on a
read-only file system.
[EFAULT] <EM>Path</EM> points outside the process's allocated address space.
[EINVAL] <EM>From</EM> is a parent directory of <EM>to</EM>, or an attempt is made to
rename ``.'' or ``..''.
[ENOTEMPTY] <EM>To</EM> is a directory and is not empty.
</PRE>
<H2>SEE ALSO</H2><PRE>
<STRONG><A HREF="../man2/open.2.html">open(2)</A></STRONG>
</PRE>
</BODY>
</HTML>