chown.2
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 153 行
2
153 行
.\" SCCSID: @(#)chown.2 8.1 9/11/90.TH chown 2.SH Namechown, fchown \- change owner and group of a file.SH Syntax.nf#include <sys/types.h>.PPchown(\fIpath, owner, group\fP)char *\fIpath\fP;uid_t \fIowner\fP;gid_t \fIgroup\fP;.PPfchown(\fIfd, owner, group\fP)int \fIfd\fP;uid_t \fIowner\fP;gid_t \fIgroup\fP;.fi.SH Description.NXR "chown system call".NXR "fchown system call".NXR "file" "changing owner".NXR "file" "changing group"The .PN chownand.PN fchownsystem calls change the owner and group of the file named by .I pathor referenced by.I fd .Only the superuser can change the ownerof a file. Other users can change the group-id of a file that they ownto another group to which they belong..PPIf you specify \-1 in \fIowner\fP or \fIgroup,\fP the corresponding owner-id orgroup-id ofthe file is unchanged..PPThe.PN chownsystem call clears the set-user-id and set-group-id bits onthe file when it returns successfully, unless the call is made by thesuperuser. Clearing these bits when a file's owner is changed protects thefile from remaining set-user-id or set-group-id after being modified.If a file, specifically a program, remained set-user-idor set-group-id after being modified, that file could allowunauthorized access to other files or accounts..PPYou should use the.PN fchownsystem call with the file locking primitives because .PN fchownpreserves any locks you previously obtained with the.PN flocksystem call. For more information about file locking, see the.MS flock 2 reference page..SH Return ValuesThe.PN chownand .PN fchowncalls return zero if the operation is successful; if an error occurs they return\-1 and store a more specificerror code in the global variable \fIerrno\fP..SH Environment.SS System Five Differs from the System V definition in that onlythe superuser can change the ownership of a file. In addition, ELOOP is a possible error condition..SS POSIXWhen your program is compiled in the POSIX environment, the.I ownerargument is of type .I uid_t, and the.I groupargument is of type .I gid_t..SH DiagnosticsThe.PN chownsystem call fails and the file is unchanged under the followingconditions:.TP 15[ENOTDIR]A component of the path prefix is not a directory..TP 15[ENAMETOOLONG]A component of a pathname exceeded 255 characters, or anentire pathname exceeded 1023 characters..TP 15[ENOENT]The named file does not exist..TP 15[EACCES]Search permission is denied for a component of the path prefix..TP 15[EPERM]The effective user-id is not the superuser..TP 15[EROFS]The named file resides on a read-only file system..TP 15[EFAULT]The pathnamepoints outside the process's allocated address space..TP 15[ELOOP]Too many symbolic links are encountered in translating the pathname..TP 15[EIO]An I/O error occurs while reading from or writing to the file system..TP 15[ESTALE]The .I fdargument is invalid because the file referredto by that file handle no longer exists or has been revoked..PPThe.PN fchownsystem call fails if:.TP 15[EBADF]The.I fdargument does not refer to a valid descriptor..TP 15[EINVAL]The.I fdargument refers to a socket, not a file..TP 15[EPERM]The effective user-id is not the superuser..TP 15[EROFS]The named file resides on a read-only file system..TP 15[EIO]An I/O error occurred while reading from or writing to thefile system..TP 15[ETIMEDOUT]A connect request or remote file operation fails because the connected partydoes not properly respond after a period of time that is dependent onthe communications protocol..SH See Alsochmod(2), flock(2)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?