4.4BSD/usr/share/man/cat2/fchown.0
CHOWN(2) BSD Programmer's Manual CHOWN(2)
NNAAMMEE
cchhoowwnn, ffcchhoowwnn - change owner and group of a file
SSYYNNOOPPSSIISS
##iinncclluuddee <<uunniissttdd..hh>>
_i_n_t
cchhoowwnn(_c_o_n_s_t _c_h_a_r _*_p_a_t_h, _u_i_d___t _o_w_n_e_r, _g_i_d___t _g_r_o_u_p);
_i_n_t
ffcchhoowwnn(_i_n_t _f_d, _u_i_d___t _o_w_n_e_r, _u_i_d___t _g_r_o_u_p);
DDEESSCCRRIIPPTTIIOONN
The owner ID and group ID of the file named by _p_a_t_h or referenced by _f_d
is changed as specified by the arguments _o_w_n_e_r and _g_r_o_u_p. The owner of a
file may change the _g_r_o_u_p to a group of which he or she is a member, but
the change _o_w_n_e_r capability is restricted to the super-user.
CChhoowwnn() clears the set-user-id and set-group-id bits on the file to pre-
vent accidental or mischievious creation of set-user-id and set-group-id
programs.
FFcchhoowwnn() is particularly useful when used in conjunction with the file
locking primitives (see flock(2)).
One of the owner or group id's may be left unchanged by specifying it as
-1.
If the final component of _p_a_t_h is a symbolic link, the ownership and
group of the symbolic link is changed, not the ownership and group of the
file or directory to which it points.
RREETTUURRNN VVAALLUUEESS
Zero is returned if the operation was successful; -1 is returned if an
error occurs, with a more specific error code being placed in the global
variable _e_r_r_n_o.
EERRRROORRSS
CChhoowwnn() will fail and the file will be unchanged if:
[ENOTDIR] A component of the path prefix is not a directory.
[EINVAL] The pathname contains a character with the high-order bit
set.
[ENAMETOOLONG]
A component of a pathname exceeded 255 characters, or an
entire path name exceeded 1023 characters.
[ENOENT] The named file does not exist.
[EACCES] Search permission is denied for a component of the path
prefix.
[ELOOP] Too many symbolic links were encountered in translating the
pathname.
[EPERM] The effective user ID is not the super-user.
[EROFS] The named file resides on a read-only file system.
[EFAULT] _P_a_t_h points outside the process's allocated address space.
[EIO] An I/O error occurred while reading from or writing to the
file system.
FFcchhoowwnn() will fail if:
[EBADF] _F_d does not refer to a valid descriptor.
[EINVAL] _F_d refers to a socket, not a file.
[EPERM] The effective user ID is not the super-user.
[EROFS] The named file resides on a read-only file system.
[EIO] An I/O error occurred while reading from or writing to the
file system.
SSEEEE AALLSSOO
chown(8), chgrp(1), chmod(2), flock(2)
SSTTAANNDDAARRDDSS
CChhoowwnn() is expected to conform to IEEE Std 1003.1-1988 (``POSIX'').
HHIISSTTOORRYY
The ffcchhoowwnn() function call appeared in 4.2BSD.
4th Berkeley Distribution June 4, 1993 2