xref: /minix3/minix/man/man2/chown.2 (revision 433d6423c39e34ec4b79c950597bb2d236f886be)
Copyright (c) 1980 Regents of the University of California.
All rights reserved. The Berkeley software License Agreement
specifies the terms and conditions for redistribution.

@(#)chown.2 6.6 (Berkeley) 5/22/86

CHOWN 2 "May 22, 1986"
C 4
NAME
chown, fchown - change owner and group of a file
SYNOPSIS
int chown(const char *path, int owner, int group)

int fchown(int fd, int owner, int group) ..

DESCRIPTION
The file that is named by path or referenced by fd .. has its owner and group changed as specified. Only the super-user may change the owner of the file, because if users were able to give files away, they could defeat file-space accounting procedures. The owner of the file may change the group to a group of which he is a member.

On some systems, chown clears the set-user-id and set-group-id bits on the file to prevent accidental creation of set-user-id and set-group-id programs.

"RETURN VALUE
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 errno.
"ERRORS
Chown will fail and the file will be unchanged if:

15 [ENOTDIR] A component of the path prefix is not a directory.

15 [ENAMETOOLONG] The path name exceeds PATH_MAX characters.

15 [ENOENT] The named file does not exist.

15 [EACCES] Search permission is denied for a component of the path prefix.

15 [ELOOP] Too many symbolic links were encountered in translating the pathname.

15 [EPERM] The effective user ID is not the super-user.

15 [EROFS] The named file resides on a read-only file system.

15 [EFAULT] Path points outside the process's allocated address space.

15 [EIO] An I/O error occurred while reading from or writing to the file system.

Fchown will fail if:

15 [EBADF] Fd does not refer to a valid descriptor.

15 [EPERM] The effective user ID is not the super-user.

15 [EROFS] The named file resides on a read-only file system.

15 [EIO] An I/O error occurred while reading from or writing to the file system. ..

"SEE ALSO"
chown (8), chgrp (1), chmod (2).