Index of Section 2 Manual Pages

Interix / SUAfchmod.2Interix / SUA

fchmod(2)                                                     fchmod(2)

  chmod()

  NAME

    chmod(), wcs_chmod(), fchmod() - change mode of file

  SYNOPSIS

    #include 

    int chmod (const char *path, mode_t mode)
    int wcs_chmod (const wchar_t *path, mode_t mode)
    int fchmod (int fildes, mode_t mode)

  DESCRIPTION

    The chmod(2) and wcs_chmod(2) functions are identical, except that
    wcs_chmod(2) accepts wide characters in the path argument.

    The chmod(2) and wcs_chmod(2) set the file permission bits of the file
    specified by the pathname path to mode. The fchmod(2) function does the
    same, except that the file is specified by the file descriptor filedes.

    The chmod(2), wcs_chmod(2), and fchmod(2) functions verify that the
    process owner (user) owns the file specified by path. A mode is created
    from OR'd permission bit masks defined in :
    Symbol      Value       Meaning

    S_IRWXU     0000700     RWX mask for owner

    S_IRUSR     0000400     R for owner

    S_IWUSR     0000200     W for owner

    S_IXUSR     0000100     X for owner

    S_IRWXG     0000070     RWX mask for group

    S_IRGRP     0000040     R for group

    S_IWGRP     0000020     W for group

    S_IXGRP     0000010     X for group

    S_IRWXO     0000007     RWX mask for other

    S_IROTH     0000004     R for other

    S_IWOTH     0000002     W for other

    S_IXOTH     0000001     X for other

    S_ISUID     0004000     set user ID on execution; see NOTES later in
                            this topic

    S_ISGID     0002000     set group ID on execution; see NOTES later in
                            this topic

    Calling the chmod(2) or wcs_chmod(2) function on a file with open file
    descriptors has no effect on the open file descriptors.

  RETURN VALUES

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

  ERRORS

    The chmod(2) or wcs_chmod(2) function will fail and the file mode will be
    unchanged if:

    [EACCES]
        Search permission is denied for a component of the path prefix.

    [EFAULT]
        Path points outside the process's allocated address space.

    [EINVAL]
        The pathname contains a character with the high-order bit set, or the
        operation is not valid on this type of file (such as a pipe or a
        socket).

    [EIO]
        An I/O error occurred while reading from or writing to the file
        system.

    [ENAMETOOLONG]

        A component of a pathname exceeded {NAME_MAX} characters, or an entire
        pathname exceeded {PATH_MAX} characters.

    [ENOENT]
        The named file does not exist.

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

    [ELOOP]
        Too many symbolic links were encountered in translating the pathname.

    [EOPNOTSUPP ]
        The mode argument specified permissions other than S_IRWXU, S_IRWXG,
        and S_IRWXO for a file on a file system that doesn't support the
        additional permissions.

    [EPERM]
        The effective user ID does not match the owner of the file.

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

    The fchmod(2) function can fail for the following reasons:

    [EBADF]
        The fildes is not an open file descriptor.

    [EINTR]
        The call was interrupted by a signal.

    [EINVAL]
        The mode was invalid, or the operation is not valid on this type of
        file (such as a pipe or a socket).

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

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

  NOTES

    When you use chmod(2), wcs_chmod(2), or fchmod(2) to make a file
    writeable, the function will unset the Win32 Read-Only attribute, if it is
    set on the file. (If the Read-Only attribute is set, the stat(2) function
    will report that the file is not writeable, regardless of the permissions
    on the ACLs associated with the file.)

    By default, Interix does not execute files with the set-user-ID (setuid)
    or set-group-ID (setgid) mode bit set for security reasons. If an attempt
    is made to execute such a file, the ENOSETUID error is returned. For more
    information and and instructions for enabling execution of files with
    these mode bits set, see The superuser account and appropriate privileges
    in Windows Services for UNIX Help.

  SEE ALSO

    chmod(1)

    open(2)

    chown(2)

    stat(2)

    privileges(5)

  USAGE NOTES

    All of these functions are thread safe.

    All of these functions are async-signal safe.


Interix / SUAHosted at SUA Community for Interix, SUA and SFUInterix / SUA