[ Previous | Next | Table of Contents | Index | Library Home |
Legal |
Search ]
Technical Reference: Base Operating System and Extensions, Volume 1
Changes file ownership.
Standard C Library
(libc.a)
Syntax for the chown,
fchown, and lchown Subroutines:
#include <sys/types.h>
#include <unistd.h>
int chown ( Path, Owner, Group)
const char *Path;
uid_t Owner;
gid_t Group;
int fchown ( FileDescriptor,
Owner, Group)
int FileDescriptor;
uid_t Owner;
gid_t Group;
int lchown (
Path, Owner, Group)
const char
*fname
uid_t uid
gid_tgid
Syntax for the chownx and
fchownx Subroutines:
#include <sys/types.h>
#include <sys/chownx.h>
int chownx (Path,
Owner, Group, Flags)
char *Path;
uid_t Owner;
gid_t Group;
int Flags;
int fchownx (FileDescriptor, Owner, Group, Flags)
int FileDescriptor;
uid_t Owner;
gid_t Group;
int Flags;
The chown,
chownx, fchown, fchownx, and lchown
subroutines set the file owner and group IDs of the specified file system
object. Root user authority is required to change the owner of a
file.
A function lchown
function sets the owner ID and group ID of the named file similarity to
chown function except in the case where the named file is a
symbolic link. In this case lchown function changes the
ownership of the symbolic link file itself, while chown function
changes the ownership of the file or directory to which the symbolic link
refers.
FileDescriptor
| Specifies the file descriptor of an open file.
|
Flags
| Specifies whether the file owner ID or group ID should be changed.
This parameter is constructed by logically ORing the following values:
- T_OWNER_AS_IS
- Ignores the value specified by the Owner parameter and leaves
the owner ID of the file unaltered.
- T_GROUP_AS_IS
- Ignores the value specified by the Group parameter and leaves
the group ID of the file unaltered.
|
Group
| Specifies the new group of the file. If this value is -1, the
group is not changed. (A value of -1 indicates only that the group is
not changed; it does not indicate a group that is not valid. An
owner or group ID cannot be invalid.)
|
Owner
| Specifies the new owner of the file. If this value is -1, the
owner is not changed. (A value of -1 indicates only that the group is
not changed; it does not indicate a group that is not valid. An
owner or group ID cannot be invalid.)
|
Path
| Specifies the full path name of the file. If Path
resolves to a symbolic link, the ownership of the file or directory pointed to
by the symbolic link is changed.
|
Upon successful completion, the
chown, chownx, fchown, fchownx,
and lchown subroutines return a value of 0. If the
chown, chownx, fchown, fchownx, or
lchown subroutine is unsuccessful, a value of -1 is returned and
the errno global variable is set to indicate the error.
The chown, chownx,
or lchown subroutine is unsuccessful and the owner and group of a
file remain unchanged if one of the following is true:
EACCESS
| Search permission is denied on a component of the Path
parameter.
|
EDQUOT
| The new group for the file system object cannot be set because the
group's quota of disk blocks or i-nodes has been exhausted on the file
system.
|
EFAULT
| The Path parameter points to a location outside of the
allocated address space of the process.
|
EINVAL
| The owner or group ID supplied is not valid.
|
ELOOP
| Too many symbolic links were encountered in translating the
Path parameter.
|
ENAMETOOLONG
| A component of the Path parameter exceeded 255 characters, or
the entire Path parameter exceeded 1023 characters.
|
ENOENT
| A symbolic link was named, but the file to which it refers does not
exist; or a component of the Path parameter does not
exist; or the process has the disallow truncation attribute
set; or the Path parameter is null.
|
ENOTDIR
| A component of the path prefix is not a directory.
|
EPERM
| The effective user ID does not match the owner of the file, and the
calling process does not have the appropriate privileges.
|
EROFS
| The named file resides on a read-only file system.
|
ESTALE
| The root or current directory of the process is located in a virtual file
system that has been unmounted.
|
The fchown or
fchownx subroutine is unsuccessful and the file owner and group
remain unchanged if one of the following is true:
EBADF
| The named file resides on a read-only file system.
|
EDQUOT
| The new group for the file system object cannot be set because the
group's quota of disk blocks or i-nodes has been exhausted on the file
system.
|
EIO
| An I/O error occurred during the operation.
|
Access Control: The invoker
must have search permission for all components of the Path
parameter.
[ Previous | Next | Table of Contents | Index |
Library Home |
Legal |
Search ]