__fchattr() — Change the attributes of a file or directory by file descriptor

Standards

Standards / Extensions C or C++ Dependencies

z/OS® UNIX

both z/OS V1R2

Format

#define _OPEN_SYS_FILE_EXT 1
#include <sys/stat.h>

int __fchattr(int filedes, attrib_t *attributes, int attributes_len);

General description

The __fchattr() function modifies the attributes that are associated with a file. It can be used to change the mode, owner, access time, modification time, change time, reference time, audit flags, general attribute flags, file tag, and file format and size. The file to be impacted is defined by its file descriptor with the filedes argument.

The attributes argument is the address of an attrib_t structure which is used to identify the attributes to be modified and the new values desired. The attrib_t type is an f_attributes structure as defined in <sys/stat.h> for use with the __fchattr() function. For proper behavior, the user should ensure that this structure has been initialized to zeros before it is populated. The f_attributes structure is defined as indicated in Table 1.

The f_attributes structure is defined in <sys/stat.h> for use with the __fchattr() function.

Returned value

If successful, __fchattr() returns 0.

If unsuccessful, __fchattr() returns -1 and sets errno to one of the following values:

Error Code
Description
EACCES
The calling process did not have appropriate permissions. Possible reasons include:
  • The calling process was attempting to set access time or modification time to current time, and the effective UID of the calling process does not match the owner of the file; the process does not have write permission for the file; or the process does not have appropriate privileges.
  • The calling process was attempting to truncate the file, and it does not have write permission for the file.
EBADF
The filedes parameter is not a valid file descriptor.
ECICS
An attempt was made to change file tag attributes under non-OTE CICS® and file tagging is not supported in that environment.
EFBIG
The calling process was attempting to change the size of a file but the specified length is greater than the maximum file size limit for the process.
EINVAL
The attributes structure containing the requested changes is not valid.
EPERM
The operation is not permitted for one of the following reasons:
  • The calling process was attempting to change the mode or the file format but the effective UID of the calling process does not match the owner of the file, and the calling process does not have appropriate privileges.
  • The calling process was attempting to change the owner but it does not have appropriate privileges.
  • The calling process was attempting to change the general attribute bits but it does not have write permission for the file.
  • The calling process was attempting to set a time value (not current time) but the effective UID does not match the owner of the file, and it does not have appropriate privileges.
  • The calling process was attempting to set the change time or reference time to current time but it does not have write permission for the file.
  • The calling process was attempting to change auditing flags but the effective UID of the calling process does not match the owner of the file, and the calling process does not have appropriate privileges.
  • The calling process was attempting to change the Security Auditor's auditing flags but the user does not have auditor authority.
EROFS
pathname specifies a file that is on a read-only file system.

Related information