|
Basic Solution File System - BSFS
|
Implementation of logical file removal in BSFS. More...
Functions | |
| int | remove_file (FILE *disk, superblock_t *sb, btree_handle_t *inode_tree, btree_handle_t *rec_tree, const char *path, dir_t *cwd, uint16_t uid) |
| Logically remove a file and snapshot it into the Recovery tree. | |
Implementation of logical file removal in BSFS.
Removal here is logical: the file is unlinked from its directory and its inode is removed from the inode tree, but blocks are not freed. A snapshot is inserted into the Recovery tree to allow later restoration or purging.
| int remove_file | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| btree_handle_t * | inode_tree, | ||
| btree_handle_t * | rec_tree, | ||
| const char * | path, | ||
| dir_t * | cwd, | ||
| uint16_t | uid ) |
Logically remove a file and snapshot it into the Recovery tree.
Unlinks the directory entry for path, removes the file's inode from the inode tree (without freeing its data blocks), and inserts a snapshot of the file metadata into the Recovery B-tree to enable later restoration or purge.
Steps: 1) Resolve the parent directory and basename from path. 2) Lookup the file inode (must not be a directory). 3) Build and insert a rec_entry_t snapshot into the Recovery tree. 4) Remove the directory entry from its parent. 5) Remove the inode from the inode tree. 6) Update parent directory timestamps.
Rollback: If step 4 or 5 fails, the inserted recovery entry is removed to keep metadata consistent.
| disk | Open filesystem image. |
| sb | Loaded superblock. |
| inode_tree | Inode B-tree handle. |
| rec_tree | Recovery B-tree handle. |
| path | Absolute or relative path of the file to remove. |
| cwd | Current working directory (for resolving relative paths). |
| uid | Caller user id (currently unused; permission checks may use it). |