fchmod

Changes the mode of the specified file.

Library:LibC
Classification:POSIX
Service:File and Directory I/O

Syntax

  #include <sys/stat.h> 
   
  int fchmod (
     int      fildes,
     mode_t   mode);
  

Parameters

fildes

(IN) Specifies the file descriptor of the file to change.

mode

(IN) Specifies the mode for the file, or on NetWare file systems, file and directory attributes (see File Access Modes and NetWare Attributes).

Return Values

If successful, returns 0. Otherwise, returns -1 and sets errno to one of the following:

Decimal

Constant

Description

1

ENOENT

A component of path does not name an existing file or pathname is an empty string.

4

EBADF

The fides parameter does not specify an open file.

9

EINVAL

The value of the mode argument is invalid.

63

EINTR

A signal was caught during execution of the function.

69

EPERM

The caller does not have appropriate privileges.

76

EROFS

The named file resides on a read-only file system.

Remarks

The various mode settings are defined in the sys/mode.h header file and described in File Access Modes and NetWare Attributes.

On NetWare file systems, you can use chmod to set file and directory attributes. If the M_A_BITS_SIGNIFICANT is set in the mode parameter, it means that the mode is being used to set the file and directory attributes. This functionality is mutually-exclusive of the normal chmod functionality:

  • If the M_A_BITS_SIGNIFICANT bit is set, only the NetWare-specific attribute bits are used and the user, group, and other flags are ignored.

  • If it is not set, the NetWare-specific flags are not examined.

See Also