17 PANIC (
"bitmap creation failed--file system device is too large");
58 PANIC (
"can't open free map");
60 PANIC (
"can't read free map");
77 PANIC (
"free map creation failed");
82 PANIC (
"can't open free map");
84 PANIC (
"can't write free map");
void bitmap_set_multiple(struct bitmap *b, size_t start, size_t cnt, bool value)
Sets the CNT bits starting at START in B to VALUE.
size_t bitmap_scan_and_flip(struct bitmap *b, size_t start, size_t cnt, bool value)
Finds the first group of CNT consecutive bits in B at or after START that are all set to VALUE,...
bool bitmap_all(const struct bitmap *b, size_t start, size_t cnt)
Returns true if every bit in B between START and START + CNT, exclusive, is set to true,...
void bitmap_mark(struct bitmap *b, size_t bit_idx)
Atomically sets the bit numbered BIT_IDX in B to true.
struct bitmap * bitmap_create(size_t bit_cnt)
Creation and destruction.
#define BITMAP_ERROR
Finding set or unset bits.
block_sector_t block_size(struct block *block)
Returns the number of sectors in BLOCK.
uint32_t block_sector_t
Index of a block device sector.
#define ASSERT(CONDITION)
This is outside the header guard so that debug.h may be included multiple times with different settin...
#define PANIC(...)
Halts the OS, printing the source file name, line number, and function name, plus a user-specific mes...
void file_close(struct file *file)
Closes FILE.
struct file * file_open(struct inode *inode)
Opens a file for the given INODE, of which it takes ownership, and returns the new file.
struct block * fs_device
Partition that contains the file system.
#define ROOT_DIR_SECTOR
Root directory file inode sector.
#define FREE_MAP_SECTOR
Sectors of system file inodes.
void free_map_init(void)
Initializes the free map.
void free_map_release(block_sector_t sector, size_t cnt)
Makes CNT sectors starting at SECTOR available for use.
void free_map_open(void)
Opens the free map file and reads it from disk.
void free_map_create(void)
Creates a new free map file on disk and writes the free map to it.
bool free_map_allocate(size_t cnt, block_sector_t *sectorp)
Allocates CNT consecutive sectors from the free map and stores the first into *SECTORP.
static struct file * free_map_file
Free map file.
static struct bitmap * free_map
Free map, one bit per sector.
void free_map_close(void)
Writes the free map to disk and closes the free map file.
struct inode * inode_open(block_sector_t sector)
Reads an inode from SECTOR and returns a ‘struct inode’ that contains it.
bool inode_create(block_sector_t sector, off_t length)
Initializes an inode with LENGTH bytes of data and writes the new inode to sector SECTOR on the file ...
From the outside, a bitmap is an array of bits.