|
Basic Solution File System - BSFS
|
Interface for inode management operations in the BSFS file system. More...
Functions | |
| int | read_inode (FILE *disk, btree_handle_t *handle, uint32_t inode_number, inode_t *out_inode) |
| Reads an inode from the inode B-tree. | |
| int | insert_inode (FILE *disk, superblock_t *sb, btree_handle_t *handle, const inode_t *inode) |
| Inserts a new inode into the inode B-tree. | |
| int | update_inode (FILE *disk, btree_handle_t *handle, const inode_t *inode) |
| Updates an existing inode in the B-tree. | |
| int | remove_inode (FILE *disk, superblock_t *sb, btree_handle_t *handle, uint32_t inode_number) |
| Removes an inode from the inode B-tree. | |
| uint32_t | get_next_inode_number (FILE *disk, btree_handle_t *inode_tree) |
| Finds the next available inode number by scanning the inode B-tree. | |
| int | inode_exists (FILE *disk, btree_handle_t *inode_tree, uint32_t inode_number) |
| Checks if an inode with the given number exists in the inode B-tree. | |
| int | inode_tree_init (FILE *disk, superblock_t *sb, btree_handle_t *out) |
| Initialize (or load) the inode B-tree handle. | |
Interface for inode management operations in the BSFS file system.
This header defines functions for manipulating inodes in the BSFS file system. It provides operations to insert, read, update, and delete inodes within the B-tree structure dedicated to inode storage.
These operations abstract the interaction with the underlying B-tree and ensure that inode access remains consistent, modular, and type-safe.
| uint32_t get_next_inode_number | ( | FILE * | disk, |
| btree_handle_t * | inode_tree ) |
Finds the next available inode number by scanning the inode B-tree.
This function scans the inode tree to find the highest inode number in use and returns the next available one. This ensures uniqueness of inode numbers without reusing deleted ones.
| disk | Pointer to the disk file. |
| inode_tree | Pointer to the B-tree handle for inodes. |
| int inode_exists | ( | FILE * | disk, |
| btree_handle_t * | inode_tree, | ||
| uint32_t | inode_number ) |
Checks if an inode with the given number exists in the inode B-tree.
This function performs a lookup in the inode B-tree to determine whether an inode with the specified number is currently present in the file system.
| disk | Pointer to the file representing the disk. |
| inode_tree | Pointer to the B-tree handle managing inodes. |
| inode_number | The inode number to check for existence. |
| int inode_tree_init | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| btree_handle_t * | out ) |
Initialize (or load) the inode B-tree handle.
If the inode root does not exist yet in the superblock, this function allocates a fresh root node on disk (empty leaf), persists it, and stores the block number in both the handle and the superblock (via write_superblock). If the root already exists, the handle is configured to point to it.
| disk | Open filesystem image. |
| sb | Loaded superblock (may be updated/persisted if creating root). |
| out | Output: initialized inode B-tree handle (by value). |
| int insert_inode | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| btree_handle_t * | handle, | ||
| const inode_t * | inode ) |
Inserts a new inode into the inode B-tree.
| disk | Pointer to the open filesystem image. |
| sb | Pointer to the superblock (for block allocation). |
| handle | Pointer to the B-tree handle for inode management. |
| inode | Pointer to the inode to be inserted. |
| int read_inode | ( | FILE * | disk, |
| btree_handle_t * | handle, | ||
| uint32_t | inode_number, | ||
| inode_t * | out_inode ) |
Reads an inode from the inode B-tree.
| disk | Pointer to the open filesystem image. |
| handle | Pointer to the B-tree handle for inode management. |
| inode_number | The unique identifier of the inode to read. |
| out_inode | Pointer to the inode_t structure to store the result. |
| int remove_inode | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| btree_handle_t * | handle, | ||
| uint32_t | inode_number ) |
Removes an inode from the inode B-tree.
This function removes the inode entry with the specified inode number from the B-tree structure.
| disk | Pointer to the open filesystem image. |
| sb | Pointer to the superblock (needed for possible deallocations). |
| handle | Pointer to the B-tree handle for inode management. |
| inode_number | The inode number to be removed. |
| int update_inode | ( | FILE * | disk, |
| btree_handle_t * | handle, | ||
| const inode_t * | inode ) |
Updates an existing inode in the B-tree.
| disk | Pointer to the open filesystem image. |
| handle | Pointer to the B-tree handle for inode management. |
| inode | Pointer to the modified inode to be written back. |