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. [Edit]

public void SetOwner (string owner)

See Also

UnixUserInfo
Mono.Unix.Native.Syscall.chown

Parameters

owner
A string containing the user name to use for the new user-id and group-id. [Edit]

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] [Edit]
UnauthorizedAccessExceptionSearch permission is denied for a component of the path UnixFileSystemInfo.FullName. [Mono.Unix.Native.Errno.EACCES] [Edit]
System.IO.DirectoryNotFoundException A component of the path prefix of UnixFileSystemInfo.FullName is not a directory. [Mono.Unix.Native.Errno.ENOTDIR] [Edit]
System.IO.FileNotFoundException A component of UnixFileSystemInfo.FullName that must exist does not exist. [Mono.Unix.Native.Errno.ENOENT] [Edit]
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]

[Edit]
System.IO.PathTooLongExceptionUnixFileSystemInfo.FullName was too long. [Mono.Unix.Native.Errno.ENAMETOOLONG] [Edit]
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]

[Edit]

Remarks

The user owner is looked up in the local password database and the resulting UnixUserInfo.UserId and UnixUserInfo.GroupId are used as the new owner user id and owner group id for UnixFileSystemInfo.FullName.

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.

[Edit]

Requirements

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