chmod.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 148 行

2
148
字号
.\" SCCSID: @(#)chmod.2	2.6	8/18/87.TH chmod 2.SH Namechmod, fchmod \- change mode of file.SH Syntax.nf#include <sys/types.h>#include <sys/stat.h>.PPchmod(\fIpath, mode\fP)char *\fIpath\fP;mode_t\ \fImode\fP;.PPfchmod(\fIfd, mode\fP)int fd;mode_t\ \fImode\fP;.fi.SH Description.NXR "chmod system call".NXR "fchmod system call".NXR "file" "changing mode".NXR "file" "setting protection"The file whose nameis provided by \fIpath\fPor referenced by the descriptor.I fdhas its mode changed to.IR mode .Modes are constructed byORingcombinations of the following:.IP "S_ISUID" 12\- 04000  set user ID on execution.IP "S_ISGID"\- 02000  set group ID on execution.IP "S_ISVTX"\- 01000  save text image after execution.IP "S_IRUSR"\- 00400  read by owner.IP "S_IWUSR"\- 00200  write by owner.IP "S_IXUSR"\- 00100  execute (search on directory) by owner.IP "S_IRWXG"\- 00070  read, write, execute (search) by group.IP "S_IRWXO"\- 00007  read, write, execute (search) by others.PPIf an executable file is set up for sharing (the default),the mode S_ISVTX prevents the system fromabandoning the swap-space image of the program-text portionof the file when its last userterminates.The ability to set this bit is restricted to the superuser..PPIf the mode S_ISVTX (sticky bit) is set on a directory, an unprivilegeduser cannot delete or the rename files of other users in that directory.For more information on the sticky bit, see .MS sticky 8 ..PPOnly the owner of a file or the superuser can change the mode..PPWriting a file or changing the owner of a fileclears the set-user-id and set-group-id bits of that file. Turning offthese bits when a file is written or its owner changed protects thefile fromremaining set-user-id or set-group-id after being modified. If a file,specifically a program, remained set-user-id or set-group-id after being modified, that filecould allow unauthorized access to other files or accounts. .SH Environment.SS System FiveELOOP is a possible error condition..SH Return ValuesUpon successful completion, a value of 0 is returned.Otherwise, a value of \-1 is returned, and.PN errnois set to indicate the error..SH DiagnosticsThe.PN chmodsystem call fails and the file mode remains unchanged under thefollowing conditions:.TP 15[EACCES]Search permission is denied on a component of the path prefix..TP 15[EFAULT]The.I pathargument points outside the process's allocated address space..TP 15[EIO]An I/O error occurred while reading from or writing tothe file system..TP 15[ELOOP]Too many symbolic links were encountered in translating the pathname..TP 15[ENAMETOOLONG]A pathname component exceeds 255 characters, oran entire pathname exceeds 1023 characters..TP 15[ENOENT]The named file does not exist..TP 15[ENOTDIR]A component of the path prefix is not a directory..TP 15[EPERM]The effective user ID does not match the owner of the file andthe effective user ID is not the superuser..TP 15[EROFS]The named file resides on a read-only file system..TP 15[ESTALE]The file handle given in the argument is invalid.  Either the file referredto by that file handle no longer exists or it has been revoked..PP  The .PN fchmodsystem callfails under the following conditions: .TP 15[EBADF]The descriptor is not valid..TP 15[EINVAL]The.I fdrefers to a socket, not to a file..TP 15[EIO]An I/O error occurred while reading from or writing tothe file system..TP 15[EROFS]The file resides on a read-only file system..TP 15[ETIMEDOUT]A connect request or remote file operation failedbecause the connected partydid not respond after a periodof time determined by the communications protocol..SH See Alsoopen(2), chown(2)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?