Open System Services System Calls Reference Manual (G06.28+)
fchown(2) OSS System Calls Reference Manual
NAME
fchown - Changes the owner and group IDs of a file
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <sys/types.h> /* optional except for POSIX.1 */
#include <unistd.h>
int fchown(
int filedes,
uid_t owner,
gid_t group);
PARAMETERS
filedes Specifies a valid file descriptor.
owner Specifies a numeric value representing the owner ID.
group Specifies a numeric value representing the group ID.
DESCRIPTION
The fchown() function changes the owner and group of a file pointed to by the filedes parameter.
The fchown() function is like the chown() function except that it operates on a file descriptor
instead of a path name.
A process can change the value of the owner ID of an OSS file only if the effective user ID of the
process gives the process appropriate privileges. A process can change the value of the file
group ID if the effective user ID of the process matches the owner ID of the file or the process
has appropriate privileges. A process without appropriate privileges can change the group ID of
a file only to the value of its effective group ID or to a value in its group list. However, if the
fchown() function is successfully invoked on a file, the S_ISGID and S_ISUID bits of the
st_mode field of the stat structure are cleared unless the user has appropriate privileges.
The _POSIX_CHOWN_RESTRICTED feature is enforced for any file in the OSS file system.
Only processes with appropriate privileges can change owner IDs.
If the owner or group parameter is specified as -1 cast to the type of uid_t or gid_t, respectively,
the corresponding ID of the file is unchanged. To change only one attribute, specify the other as
-1.
Upon successful completion, the fchown() function marks the st_ctime field of the file for
update.
Use on Guardian Objects
The fchown() function can be used on Guardian disk files (that is, disk files in the /G file sys-
tem). Attempts to change the ownership of other types of Guardian files fail and set errno to
[EINVAL].
For Guardian disk files, Guardian security is used, and any user can pass file ownership to any
other user. A value other than -1 must be specified for the owner parameter (that is, an owner ID
must be specified). However, changing the owner ID also changes the group ID to the Guardian
group ID of the new owner (that is, bits <16:23> of the new access ID). The fchown() function
cannot be used to set the group ID for a Guardian file except as a result of changing the owner
ID.
3−6 Hewlett-Packard Company 527186-005