Mono Class Library: Mono.Unix.UnixFileSystemInfo Overview | Members

Mono.Unix.UnixFileSystemInfo.SetOwner Method

Set the owner user ID and owner group ID of UnixFileSystemInfo.FullName.

public virtual void SetOwner (long owner, long group)

See Also

Mono.Unix.Native.Syscall.chown

Parameters

owner
A long containing the user id of the new owner user. If -1, the owner user id is unchanged.
group
A long containing the group id of the new owner group. If -1, the owner group id is unchanged.

Exceptions

TypeReason
InvalidOperationException The effective user ID does not match the owner of the file and the effective user ID is not the super-user. [Mono.Unix.Native.Errno.EPERM]
UnauthorizedAccessExceptionSearch permission is denied for a component of the path UnixFileSystemInfo.FullName. [Mono.Unix.Native.Errno.EACCES]
System.IO.DirectoryNotFoundException A component of the path prefix of UnixFileSystemInfo.FullName is not a directory. [Mono.Unix.Native.Errno.ENOTDIR]
System.IO.FileNotFoundException A component of UnixFileSystemInfo.FullName that must exist does not exist. [Mono.Unix.Native.Errno.ENOENT]
System.IO.IOException

UnixFileSystemInfo.FullName resides on a read-only file system. [Mono.Unix.Native.Errno.EROFS]

-or-

An I/O error occurred while making the directory entry or allocating the inode. [Mono.Unix.Native.Errno.EIO]

System.IO.PathTooLongExceptionUnixFileSystemInfo.FullName was too long. [Mono.Unix.Native.Errno.ENAMETOOLONG]
Mono.Unix.UnixIOException

Too many symbolic links were encountered in translating UnixFileSystemInfo.FullName. [Mono.Unix.Native.Errno.ELOOP]

-or-

An attempt was made to set the sticky bit upon an executable. [Mono.Unix.Native.Errno.EFTYPE]

Remarks

If this is called by the non-super user (usually the root user), then the FileSpecialAttributes.SetUserId and FileSpecialAttributes.SetGroupId bits are cleared.

Classes deriving from Mono.Unix.UnixFileSystemInfo can change this method to operate on a different file. This default version will follow symbolic links, changing the permissions of the symbolic link target instead of the symbolic link itself. UnixSymbolicLinkInfo.SetOwner changes permissions on the symbolic link itself.

Requirements

Namespace: Mono.Unix
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0