sys_chown  [fs/open.c]


Changes ownership of a file.

Arguments

eax 182
ebx Pointer to a null-terminated string that specifies the name of a file.
ecx New UID. If this value is -1, the user ID is not changed.
edx New GID. If this value is -1, the group ID is not changed

Return values

If the system call succeeds the return value is 0.
If the system call fails the return value is one of the following errno values (depending on the file systems other error values may be returned):

-ENOENT The file does not exist.
-ENOMEM Insufficient kernel memory was available.
-ENOTDIR A component of the path prefix is not a directory.
-EPERM The calling process did not have the required permissions (see above) to change owner and/or group.
-EROFS The named file resides on a read-only file system.
-ENAMETOOLONG Path is too long.
-ELOOP Too many symbolic links were encountered in path resolving.
-EFAULT Path points outside your accessible address space.
-EACCESS Search permission is denied on a component of the path prefix.

Remarks

Only a process with a CAP_CHOWN capability may change the owner of a file. The owner of a file may change the group of the file to any group of which that owner is a member. A process with CAP_CHOWN may change the group arbitrarily.

The sys_chown semantics are deliberately violated on NFS file systems which have UID mapping enabled. Additionally, the semantics of all system calls which access the file contents are violated, because sys_chown may cause immediate access revocation on already open files. Client side caching may lead to a delay between the time where ownership have been changed to allow access for a user and the time where the file can actually be accessed by the user on other clients.

Compatibility

n/a