chown(2) DG/UX 5.4R3.00 chown(2)
NAME
chown, lchown - change user id and group id of a file
SYNOPSIS
#include <unistd.h>
int chown (path, user, group)
char * path;
int user;
int group;
int lchown (path, user, group)
char * path;
int user;
int group;
DESCRIPTION
Use chown and lchown to set the access of a file:
path is the pathname of the file whose access is to be changed. It
may identify a file of type ordinary, directory, FIFO, block
special, character special, or symbolic link. The file cannot
reside on a file system device mounted read-only.
user is the new user id (stuid) for the file. A value of -1
leaves the user id unchanged.
group is the new group id (stgid) for the file. A value of -1
leaves the group id unchanged.
If the call succeeds, the file's time of last attribute change
(stctime) is set to the current time. If the call fails, the user
id, group id, and attributes of the file remain unchanged.
The chown(2) and lchown(2) calls operate identically except for their
handling of symbolic links. If path is a symbolic link, lchown(2)
changes the access of the symbolic link, not that of its target. By
contrast, chown changes the access of the target of the symbolic
link.
ACCESS CONTROL
The process must have permission to resolve path.
The effective user id of the calling process must be superuser, or
match the user id of the file.
When customizing the DG/UX system, the installer or administrator may
restrict access to any file. Use of chown(2) or lchown(2) with a
restricted file is further limited as follows: (1) only the superuser
can modify a restricted file's user id; (2) a process whose effective
user ID matches the user ID of the file may change the group ID, but
only to the process's effective group ID, or to one of the process's
supplementary IDs. To find out whether access to a file is
restricted, use pathconf(2) with the _PC_CHOWN_RESTRICTED argument.
Licensed material--property of copyright holder(s) 1
chown(2) DG/UX 5.4R3.00 chown(2)
RETURN VALUE
0 The user id and group id of the file were successfully
changed.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
Errno may be set to one of the following error codes:
EPERM Permission to change the file's user and group id is
denied.
EROFS The named file resides on a file system device mounted
read-only.
ENOENT The file the pathname resolved to does not exist.
ENOENT A non-terminal component of the pathname does not
exist.
ENOTDIR A non-terminal component of the pathname was not a
directory or symbolic link.
ENAMETOOLONG The pathname exceeds the length limit for pathnames.
ENAMETOOLONG A component of the pathname exceeds the length limit
for filenames.
ENOMEM There are not enough system resources to resolve the
pathname or to expand a symbolic link.
ELOOP The number of symbolic links encountered during
pathname resolution exceeded MAXSYMLINKS. A symbolic
link cycle is suspected.
EPERM The pathname contains a character not in the allowed
character set.
EFAULT The pathname does not completely reside in the
process's address space or the pathname does not
terminate in the process's address space.
SEE ALSO
chmod(1), fchmod(2), fchown(2).
Licensed material--property of copyright holder(s) 2