|
Basic Solution File System - BSFS
|
High-level operations for directory management in the BSFS file system. More...
Functions | |
| int | create_directory (FILE *disk, superblock_t *sb, const char *path, dir_t *cwd) |
| Creates a new directory at the given path. | |
| int | remove_directory (FILE *disk, superblock_t *sb, const char *path, dir_t *cwd) |
| Deletes a directory at the given path, if it is empty. | |
| int | move_dir_entry (FILE *disk, superblock_t *sb, dir_t *src_dir, const char *src_name, dir_t *dest_dir, const char *dest_name) |
| Moves or renames a directory entry from one directory to another. | |
| int | create_root_directory (FILE *disk, superblock_t *sb) |
| Initialize and persist the root directory ("/") on a fresh image. | |
High-level operations for directory management in the BSFS file system.
This header defines functions to create, delete, rename, and move directories and files by manipulating their directory entries and associated inodes.
| int create_directory | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| const char * | path, | ||
| dir_t * | cwd ) |
Creates a new directory at the given path.
This function allocates a new inode of type directory and inserts it as an entry into the parent directory determined by the path.
| disk | Pointer to the disk file. |
| sb | Pointer to the loaded superblock. |
| path | Absolute or relative path for the new directory. |
| cwd | Current working directory (for resolving relative paths). |
| int create_root_directory | ( | FILE * | disk, |
| superblock_t * | sb ) |
Initialize and persist the root directory ("/") on a fresh image.
Creates the root inode with default ownership and permissions, allocates a directory B-tree for entries, inserts the mandatory "." and ".." entries, and ensures the inode tree contains the root inode.
| disk | Open filesystem image. |
| sb | Loaded superblock (root inode and tree roots may be updated). |
| int move_dir_entry | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| dir_t * | src_dir, | ||
| const char * | src_name, | ||
| dir_t * | dest_dir, | ||
| const char * | dest_name ) |
Moves or renames a directory entry from one directory to another.
This function removes an existing directory entry from the source directory and inserts it into the destination directory. The entry can also be renamed in the process.
| disk | Pointer to the disk file. |
| sb | Pointer to the superblock. |
| src_dir | Pointer to the source directory. |
| src_name | Name of the entry to move (existing name). |
| dest_dir | Pointer to the destination directory. |
| dest_name | New name for the entry in the destination (can be same as src_name). |
| int remove_directory | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| const char * | path, | ||
| dir_t * | cwd ) |
Deletes a directory at the given path, if it is empty.
This function removes the directory entry and deallocates the associated inode.
| disk | Pointer to the disk file. |
| sb | Pointer to the loaded superblock. |
| path | Absolute or relative path of the directory to remove. |
| cwd | Current working directory (for resolving relative paths). |