|
Basic Solution File System - BSFS
|
Implementation of low-level block I/O operations for BSFS. More...
Functions | |
| int | write_block (FILE *disk, uint32_t block_number, const void *data, size_t size) |
| Writes data to a single block. | |
| int | read_block (FILE *disk, uint32_t block_number, void *data, size_t size) |
| Reads data from a single block. | |
| int | free_block (FILE *disk, superblock_t *sb, uint32_t block_number, uint8_t *bitmap, uint32_t bitmap_size) |
| Marks a block as free in the file system. | |
Implementation of low-level block I/O operations for BSFS.
This module provides basic functions for reading and writing fixed-size blocks on disk in the BSFS file system. It also includes a utility function to free blocks and mark them as available in the block bitmap.
These functions form the foundation for all I/O operations involving disk-resident structures, including metadata trees, inodes, and data files.
All access respects the BLOCK_SIZE defined in the superblock and integrates with the bitmap for block availability tracking.
| int free_block | ( | FILE * | disk, |
| superblock_t * | sb, | ||
| uint32_t | block_number, | ||
| uint8_t * | bitmap, | ||
| uint32_t | bitmap_size ) |
Marks a block as free in the file system.
Clears the bit corresponding to block_number in the allocation bitmap and writes the updated bitmap to disk. The bitmap region location is obtained from the superblock (sb->block_bitmap_start).
| disk | Pointer to the disk file where the block is located. |
| sb | Pointer to the superblock providing bitmap location metadata. |
| block_number | The block number to be marked as free. |
| bitmap | Pointer to the in-memory bitmap buffer to update and write. |
| bitmap_size | Unused parameter (reserved for future validation). |
| int read_block | ( | FILE * | disk, |
| uint32_t | block_number, | ||
| void * | data, | ||
| size_t | size ) |
Reads data from a single block.
This function reads a block of data from the specified block number on the disk. It ensures the size of the data to be read does not exceed the block size.
| disk | Pointer to the disk file where data will be read from. |
| block_number | The block number from which the data will be read. |
| data | Pointer to the buffer where the read data will be stored. |
| size | The size of the data to be read. |
| int write_block | ( | FILE * | disk, |
| uint32_t | block_number, | ||
| const void * | data, | ||
| size_t | size ) |
Writes data to a single block.
This function writes a block of data to the specified block number on the disk. It ensures the size of the data does not exceed the block size. The data is written to the block with a full write of the block size.
| disk | Pointer to the disk file where data will be written. |
| block_number | The block number where the data will be written. |
| data | Pointer to the data to be written. |
| size | The size of the data to be written. |