Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fchown.bsd(2) — Domain/IX SR9.2.3

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

flock(2)

CHOWN(2)

NAME

chown − change owner and group of a file

USAGE

chown(path, owner, group)
char *path;
int owner, group;

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

DESCRIPTION

The file named by path or referred to by fd has its owner and group changed as specified.  Only the super-user may execute this call. 

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 owned by the super-user. 

Fchown is particularly useful when used in conjunction with the file-locking primitives (see flock(2)). 

You may set either the owner or the group ID without changing the other.  Set the ID you do not want to change to −1. 

NOTES

Files that are protected for write-only or execute-only by chown(1) or chown(2) are also made available for read access.  This is required by the Apollo I/O system. 

RETURN VALUE

Chown returns zero if the operation was successful; otherwise, it returns  −1, and sets errno. 

ERRORS

Chown will fail and the file will be unchanged if:

[EINVAL] The argument path does not refer to a file. 

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

[ENOENT] The argument pathname is too long. 

[EPERM] The argument contains a byte with the high-order bit set. 

[ENOENT] The named file does not exist. 

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

[EPERM] The effective user ID does not match the owner of the file and the effective user ID is not the super-user. 

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

[EFAULT] Path points outside the process’ allocated address space. 

[ELOOP] The call encountered too many symbolic links in translating the pathname. 

Fchown will fail if:

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

[EINVAL] Fd refers to a socket, not a file. 

RELATED INFORMATION

chmod(2), flock(2)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026