|
|
1.1 ! root 1: .\" Copyright (c) 1980 Regents of the University of California. ! 2: .\" All rights reserved. The Berkeley software License Agreement ! 3: .\" specifies the terms and conditions for redistribution. ! 4: .\" ! 5: .\" @(#)chmod.2 6.5 (Berkeley) 5/13/86 ! 6: .\" ! 7: .TH CHMOD 2 "May 13, 1986" ! 8: .UC 4 ! 9: .SH NAME ! 10: chmod \- change mode of file ! 11: .SH SYNOPSIS ! 12: .nf ! 13: .ft B ! 14: chmod(path, mode) ! 15: char *path; ! 16: int mode; ! 17: .PP ! 18: .ft B ! 19: fchmod(fd, mode) ! 20: int fd, mode; ! 21: .fi ! 22: .SH DESCRIPTION ! 23: The file whose name ! 24: is given by \fIpath\fP ! 25: or referenced by the descriptor ! 26: .I fd ! 27: has its mode changed to ! 28: .IR mode . ! 29: Modes are constructed by ! 30: .IR or 'ing ! 31: together some ! 32: combination of the following, defined in ! 33: .IR <sys/inode.h> : ! 34: .PP ! 35: .RS ! 36: .nf ! 37: .ta \w'IWRITE\ \ 'u +\w'04000\ \ \ 'u ! 38: ISUID 04000 set user ID on execution ! 39: ISGID 02000 set group ID on execution ! 40: ISVTX 01000 `sticky bit' (see below) ! 41: IREAD 00400 read by owner ! 42: IWRITE 00200 write by owner ! 43: IEXEC 00100 execute (search on directory) by owner ! 44: 00070 read, write, execute (search) by group ! 45: 00007 read, write, execute (search) by others ! 46: .fi ! 47: .RE ! 48: .PP ! 49: If an executable file is set up for sharing (this is the default) ! 50: then mode ISVTX (the `sticky bit') prevents the system from ! 51: abandoning the swap-space image of the program-text portion ! 52: of the file when its last user terminates. ! 53: Ability to set this bit on executable files is restricted to the super-user. ! 54: .PP ! 55: If mode ISVTX (the `sticky bit') is set on a directory, ! 56: an unprivileged user may not delete or rename ! 57: files of other users in that directory. ! 58: For more details of the properties of the sticky bit, see ! 59: .IR sticky (8). ! 60: .PP ! 61: Only the owner of a file (or the super-user) may change the mode. ! 62: .PP ! 63: Writing or changing the owner of a file ! 64: turns off the set-user-id and set-group-id bits ! 65: unless the user is the super-user. ! 66: This makes the system somewhat more secure ! 67: by protecting set-user-id (set-group-id) files ! 68: from remaining set-user-id (set-group-id) if they are modified, ! 69: at the expense of a degree of compatibility. ! 70: .SH "RETURN VALUE ! 71: Upon successful completion, a value of 0 is returned. ! 72: Otherwise, a value of \-1 is returned and ! 73: .I errno ! 74: is set to indicate the error. ! 75: .SH "ERRORS ! 76: .I Chmod ! 77: will fail and the file mode will be unchanged if: ! 78: .TP 15 ! 79: [ENOTDIR] ! 80: A component of the path prefix is not a directory. ! 81: .TP 15 ! 82: [EINVAL] ! 83: The pathname contains a character with the high-order bit set. ! 84: .TP 15 ! 85: [ENAMETOOLONG] ! 86: A component of a pathname exceeded 255 characters, ! 87: or an entire path name exceeded 1023 characters. ! 88: .TP 15 ! 89: [ENOENT] ! 90: The named file does not exist. ! 91: .TP 15 ! 92: [EACCES] ! 93: Search permission is denied for a component of the path prefix. ! 94: .TP 15 ! 95: [ELOOP] ! 96: Too many symbolic links were encountered in translating the pathname. ! 97: .TP 15 ! 98: [EPERM] ! 99: The effective user ID does not match the owner of the file and ! 100: the effective user ID is not the super-user. ! 101: .TP 15 ! 102: [EROFS] ! 103: The named file resides on a read-only file system. ! 104: .TP 15 ! 105: [EFAULT] ! 106: .I Path ! 107: points outside the process's allocated address space. ! 108: .TP 15 ! 109: [EIO] ! 110: An I/O error occurred while reading from or writing to the file system. ! 111: .PP ! 112: .I Fchmod ! 113: will fail if: ! 114: .TP 15 ! 115: [EBADF] ! 116: The descriptor is not valid. ! 117: .TP 15 ! 118: [EINVAL] ! 119: .I Fd ! 120: refers to a socket, not to a file. ! 121: .TP 15 ! 122: [EROFS] ! 123: The file resides on a read-only file system. ! 124: .TP 15 ! 125: [EIO] ! 126: An I/O error occurred while reading from or writing to the file system. ! 127: .SH "SEE ALSO" ! 128: chmod(1), open(2), chown(2), stat(2), sticky(8)
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.