rename.2
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 196 行
2
196 行
.\" SCCSID: @(#)rename.2 6.3 9/12/89.TH rename 2.SH Namerename \- change the name of a file.SH Syntax.nfrename(\fIfrom, to\fP)char \fI*from, *to\fP;.fi.SH Description.NXR "rename system call" .NXR "directory" "renaming".NXR "file" "renaming"The.PN renamesystem callcauses the link named.I fromto be renamed .IR to .If .I toexists, then it is first removed.Both .I fromand.I tomust be of the same type (that is, both directories or bothnondirectories) and must reside on the same file system..PPThe.PN renamesystem call guarantees that an instance of.I towill always exist, even if the system should crash inthe middle of the operation..SH Return ValuesA zero (0) value is returned if the operation succeeds. Otherwise.PN renamereturns \-1, and the global variable .I errnoindicates the reason for the failure..SH RestrictionsThe system can deadlock if a loop in the file system graph is present.andtwo processes issue the .PN rename call at the same time.For example, suppose a directory, .PN dirname ,contains a file, .PN dirname/filename .Suppose that file is hard-linked to a directory,.PN secondir , and the.PN secondirdirectory contains a file,.PN secondir/secondfile . If .PN secondir/secondfileis hard-linkedto .PN dirname ,a loop exists.Now suppose one process issues thefollowing .PN rename call:.EXrename (dirname/filename secondir/secondfile).EEAt the same time, another process issues the following .PN rename call:.EXrename (secondir/secondfile dirname/filename).EEIn this case, the system can deadlock.The system administrator should replace hard links to directories with symbolic links..SH DiagnosticsThe.PN renamesystem callfails and neither of the argument files are affected under the following conditions:.TP 15[ENOTDIR]A component of either path prefix is not a directory..TP 15[ENOENT]A component of the.I frompath does not exist, or a path prefix of.I todoes not exist..TP 15[ENOENT]Either \fIfrom\fP or \fIto\fP points to an empty string and the environmentdefined is POSIX or SYSTEM_FIVE..TP 15[EACCES]A component of either path prefix denies search permission..TP 15[EPERM]The.I tofile exists, the directory containing.I from is marked sticky, and neither thecontaining directory nor the.I to directory is owned by theeffective user ID..TP 15[EPERM] The directory containing.I fromis marked sticky,and neither the containing directory nor the.I fromdirectory is owned by the effective user ID..TP 15[EXDEV]The link named by \fIto\fP and the file named by \fIfrom\fPare on different logical devices (file systems). Note that this errorcode is not returned if the implementation permits cross-devicelinks..TP 15[EACCES]The requested link requires writing in a directory with a modethat denies write permission..TP 15[EROFS]The requested link requires writing in a directory on a read-only filesystem..TP 15[EFAULT]The.I pathpoints outside the process's allocated address space..TP 15[EINVAL]The.I fromis a parent directory of.IR to ,or an attempt is made to rename dot (.) or dot-dot (..)..TP 15[ENAMETOOLONG]A component of either pathname exceeded 255 characters,or the entire length of either pathname exceeded 1023characters..TP 15[ELOOP]Too many symbolic links were encountered in translatingeither pathname..TP 15[ENOTDIR]The.I fromis a directory, but.I tois not a directory..TP 15[EISDIR]The.I tois a directory, but.I from is not a directory..TP 15[ENOSPC]The directory in which the entry for the new name is being placedcannot be extended, because there is no space left on thefile system containing the directory..TP 15[EDQUOT]The directory in which the entry for the new nameis being placed cannot be extended, because the user'squota of disk blocks on the file system containingthe directory has been exhausted..TP 15[EIO]An I/O error occurred while making or updating adirectory entry..TP 15[ENOTEMPTY]The.I tois a directory and is not empty..TP 15[EBUSY]The directory named by \fIfrom\fP or \fIto\fP is a mount point..SH See Alsoopen(2)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?