|
Basic Solution File System - BSFS
|
Permission helper routines for BSFS (POSIX-like rwx bits). More...
Macros | |
| #define | S_IXOTH 0001 |
| #define | S_IWOTH 0002 |
| #define | S_IROTH 0004 |
| #define | S_IXGRP 0010 |
| #define | S_IWGRP 0020 |
| #define | S_IRGRP 0040 |
| #define | S_IXUSR 0100 |
| #define | S_IWUSR 0200 |
| #define | S_IRUSR 0400 |
| #define | S_ISVTX 01000 |
| #define | S_ISGID 02000 |
| #define | S_ISUID 04000 |
Functions | |
| uint16_t | bsfs_effective_mode (const inode_t *ino, uint16_t uid, uint16_t gid) |
| Compute the effective rwx mode (3 bits) for a caller on an inode. | |
| int | bsfs_can_read_file (const inode_t *file, uint16_t uid, uint16_t gid) |
| Check if caller can read a regular file. | |
| int | bsfs_can_write_file (const inode_t *file, uint16_t uid, uint16_t gid) |
| Check if caller can write to a regular file. | |
| int | bsfs_can_exec_file (const inode_t *file, uint16_t uid, uint16_t gid) |
| Check if caller can execute a regular file. | |
| int | bsfs_can_traverse_dir (const inode_t *dir, uint16_t uid, uint16_t gid) |
| Check if caller can traverse (search) a directory. | |
| int | bsfs_can_list_dir (const inode_t *dir, uint16_t uid, uint16_t gid) |
| Check if caller can list entries in a directory. | |
| int | bsfs_can_modify_dir (const inode_t *dir, uint16_t uid, uint16_t gid) |
| Check if caller can modify entries within a directory (w+x). | |
| int | bsfs_can_unlink_in_sticky (const inode_t *dir, const inode_t *entry, uint16_t uid, uint16_t gid) |
| Check unlink/rename permission in a sticky directory. | |
Permission helper routines for BSFS (POSIX-like rwx bits).
Provides centralized checks to enforce discretionary access control (DAC) using classic rwx bits on inodes. These helpers should be called from path traversal and API entry points (mkdir/rmdir/create/remove/move/open, etc.) rather than from low-level I/O primitives.
| #define S_IRGRP 0040 |
Read permission for group.
| #define S_IROTH 0004 |
Read permission for others.
| #define S_IRUSR 0400 |
Read permission for owner.
| #define S_ISGID 02000 |
Set-GID bit.
| #define S_ISUID 04000 |
Set-UID bit.
| #define S_ISVTX 01000 |
Sticky bit (restricts unlink/rename in dir).
| #define S_IWGRP 0020 |
Write permission for group.
| #define S_IWOTH 0002 |
Write permission for others.
| #define S_IWUSR 0200 |
Write permission for owner.
| #define S_IXGRP 0010 |
Execute/search permission for group.
| #define S_IXOTH 0001 |
Execute/search permission for others.
| #define S_IXUSR 0100 |
Execute/search permission for owner.
| int bsfs_can_exec_file | ( | const inode_t * | file, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check if caller can execute a regular file.
| file | Target inode. |
| uid | Caller user id. |
| gid | Caller group id. |
| int bsfs_can_list_dir | ( | const inode_t * | dir, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check if caller can list entries in a directory.
| dir | Directory inode. |
| uid | Caller user id. |
| gid | Caller group id. |
| int bsfs_can_modify_dir | ( | const inode_t * | dir, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check if caller can modify entries within a directory (w+x).
| dir | Directory inode. |
| uid | Caller user id. |
| gid | Caller group id. |
| int bsfs_can_read_file | ( | const inode_t * | file, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check if caller can read a regular file.
| file | Target inode. |
| uid | Caller user id. |
| gid | Caller group id. |
| int bsfs_can_traverse_dir | ( | const inode_t * | dir, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check if caller can traverse (search) a directory.
| dir | Directory inode. |
| uid | Caller user id. |
| gid | Caller group id. |
| int bsfs_can_unlink_in_sticky | ( | const inode_t * | dir, |
| const inode_t * | entry, | ||
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check unlink/rename permission in a sticky directory.
If the directory has sticky bit set (S_ISVTX), only root, the directory owner, or the entry owner may remove/rename entries inside it.
| dir | Parent directory inode. |
| entry | Entry inode (file or subdirectory) to remove/rename. |
| uid | Caller user id. |
| gid | Caller group id (unused here). |
| int bsfs_can_write_file | ( | const inode_t * | file, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Check if caller can write to a regular file.
| file | Target inode. |
| uid | Caller user id. |
| gid | Caller group id. |
| uint16_t bsfs_effective_mode | ( | const inode_t * | ino, |
| uint16_t | uid, | ||
| uint16_t | gid ) |
Compute the effective rwx mode (3 bits) for a caller on an inode.
| ino | Target inode. |
| uid | Caller user id. |
| gid | Caller group id. |