Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ chmod(S) — OpenDesktop Software Development System 3.0.0

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chown(S)

chmod(C)

creat(S)

fcntl(S)

mknod(S)

open(S)

read(S)

write(S)


 chmod(S)                       6 January 1993                       chmod(S)


 Name

    chmod - change mode of file

 Syntax


    cc  . . .  -lc


    int chmod (path, mode)
    char *path;
    int mode;


 Description

    The path argument points to a path name naming a file.  The chmod system
    call sets the access permission portion of the named file's mode accord-
    ing to the bit pattern contained in mode.

    Access permission bits are interpreted as follows:

    04000     Set user ID on execution.

    020#0     Set group ID on execution if # is ``7'', ``5'', ``3'', or ``1''
              Enable mandatory file/record locking if # is ``6'', ``4'',
              ``2'', or ``0''

    01000     Save text image after execution.

    00400     Read by owner.

    00200     Write by owner.

    00100     Execute (search if a directory) by owner.

    00070     Read, write, execute  (search) by group.

    00007     Read, write, execute  (search) by others.

    The effective user ID of the process must match the owner of the file or
    be super-user to change the mode of a file.

    If the effective user ID of the process is not super-user and the file is
    not a directory, mode bit 01000 (save text image on execution) is
    cleared.

    If the effective user ID of the process is not super-user and the effec-
    tive group ID of the process does not match the group ID of the file,
    mode bit 02000 (set group ID on execution) is cleared.

    If a 410 executable file has the sticky bit (mode bit 01000) set, the op-
    erating system will not delete the program text from the swap area when
    the last user process terminates.  If a 413 executable file has the
    sticky bit set, the operating system will not delete the program text
    from memory when the last user process terminates.  In either case, if
    the sticky bit is set, the text will already be available (either in a
    swap area or in memory) when the next user of the file executes it, thus
    making execution faster.

    Overall, if a directory is writable and has the sticky bit set, files
    within that directory can only be removed if one or more of the following
    is true (see unlink(S)):

    +  the user owns the file

    +  the user owns the directory

    +  the file is writable to the user

    +  the user is the super-user

    If the mode bit 02000 (set group ID on execution) is set and the mode bit
    00010 (execute or search by group) is not set, mandatory file/record
    locking will exist on a regular file.  This may effect future calls to
    open(S), creat(S), read(S), and write(S) on this file.

    chmod will fail and the file mode will be unchanged if one or more of the
    following is true:

    [ENOTDIR]   A component of the path prefix is not a directory.

    [ENOENT]    The named file does not exist.

    [EACCES]    Search permission is denied on a component of the path pre-
                fix.

    [EPERM]     The effective user ID does not match the owner of the file
                and the effective user ID is not super-user.

    [EROFS]     The named file resides on a read-only file system.

    [EFAULT]    path points outside the allocated address space of the pro-
                cess.

    [EINTR]     A signal was caught during the chmod system call.

    [ENOLINK]   path points to a remote machine and the link to that machine
                is no longer active.

    [EMULTIHOP] Components of path require hopping to multiple remote ma-
                chines.


 Diagnostics

    Upon successful completion, a value of 0 is returned.  Otherwise, a value
    of -1 is returned and errno is set to indicate the error.

 See also

    chown(S), chmod(C), creat(S), fcntl(S), mknod(S), open(S), read(S),
    write(S)

 Standards conformance

    chmod conforms with:
    AT&T SVID Issue 2;
    X/Open Portability Guide, Issue 3, 1989;
    Intel386 Binary Compatibility Specification, Edition 2 (iBCSe2);
    IEEE POSIX Std 1003.1-1990 System Application Program Interface (API) [C
    Language] (ISO/IEC 9945-1);
    and NIST FIPS 151-1.


Typewritten Software • bear@typewritten.org • Edmonds, WA 98026