Module: fs.perm

Source: ./fs/perm.reef


Overview

fs/perm - File permission operations

Provides chmod, chown, permission testing, and POSIX permission constants.

Permission modification and the set_executable/set_readonly convenience helpers return Result[bool, error.Error]: Ok(true) on success (the void-success convention — never Ok(false)), Err(NotFound) when the path does not exist, Err(PermissionDenied) for any other chmod/chown/lchown failure (the dominant real-world cause once existence is ruled out). set_executable/set_readonly compose fs.stat.file_mode's Result to read the current mode, propagating its Err unchanged on failure.


Functions

fn perm_failure_kind(path: string): error.ErrorKind

Classifies a chmod/chown/lchown failure for path: NotFound if the path doesn't exist at all, PermissionDenied for any other reason (the dominant real-world cause once existence is ruled out — e.g. EPERM, read-only filesystem, not the owner). Mirrors fs.stat's exists()-recheck pattern.

fn chmod(path: string, mode: int): result.Result[bool, error.Error]

Changes path's permission bits to mode. Ok(true) on success (the void-success convention). Err(NotFound) if path doesn't exist, Err(PermissionDenied) for any other failure.

fn chown(path: string, uid: int, gid: int): result.Result[bool, error.Error]

Changes path's owning uid/gid (following symlinks). Ok(true) on success. Err(NotFound) if path doesn't exist, Err(PermissionDenied) for any other failure (commonly EPERM — chown requires privilege).

fn lchown(path: string, uid: int, gid: int): result.Result[bool, error.Error]

Changes path's owning uid/gid without following symlinks. Same Ok/Err contract as chown.

fn set_executable(path: string): result.Result[bool, error.Error]

Add execute permission for user, group, and other Sets mode to current | 0111 (user+group+other execute)

Composes fs.stat.file_mode's Result to read the current mode: its Err (NotFound/IoError) is propagated unchanged; on Ok, chmod's own Result (NotFound/PermissionDenied) is returned. Ok(true) on success.

fn set_readonly(path: string): result.Result[bool, error.Error]

Remove write permission for user, group, and other Sets mode to current & ~0222

Same composition contract as set_executable: propagates fs.stat.file_mode's Err unchanged, otherwise returns chmod's Result.

fn is_readable(path: string): bool

fn is_writable(path: string): bool

fn is_executable(path: string): bool

fn S_IRUSR(): int

fn S_IWUSR(): int

fn S_IXUSR(): int

fn S_IRGRP(): int

fn S_IWGRP(): int

fn S_IXGRP(): int

fn S_IROTH(): int

fn S_IWOTH(): int

fn S_IXOTH(): int

fn S_ISUID(): int

fn S_ISGID(): int

fn S_ISVTX(): int


Generated by reefc doc