22 PANIC (
"No file system device found, can't initialize file system.");
54 if (!success && inode_sector != 0)
97 printf (
"Formatting file system...");
100 PANIC (
"root directory creation failed");
struct block * block_get_role(enum block_type role)
Returns the block device fulfilling the given ROLE, or a null pointer if no block device has been ass...
uint32_t block_sector_t
Index of a block device sector.
@ BLOCK_FILESYS
File system.
#define PANIC(...)
Halts the OS, printing the source file name, line number, and function name, plus a user-specific mes...
bool dir_lookup(const struct dir *dir, const char *name, struct inode **inode)
Searches DIR for a file with the given NAME and returns true if one exists, false otherwise.
bool dir_add(struct dir *dir, const char *name, block_sector_t inode_sector)
Adds a file named NAME to DIR, which must not already contain a file by that name.
void dir_close(struct dir *dir)
Destroys DIR and frees associated resources.
bool dir_create(block_sector_t sector, size_t entry_cnt)
Creates a directory with space for ENTRY_CNT entries in the given SECTOR.
bool dir_remove(struct dir *dir, const char *name)
Removes any entry for NAME in DIR.
struct dir * dir_open_root(void)
Opens the root directory and returns a directory for it.
struct file * file_open(struct inode *inode)
Opens a file for the given INODE, of which it takes ownership, and returns the new file.
static void do_format(void)
Formats the file system.
struct block * fs_device
Partition that contains the file system.
struct file * filesys_open(const char *name)
Opens the file with the given NAME.
bool filesys_remove(const char *name)
Deletes the file named NAME.
void filesys_done(void)
Shuts down the file system module, writing any unwritten data to disk.
void filesys_init(bool format)
Initializes the file system module.
bool filesys_create(const char *name, off_t initial_size)
Creates a file named NAME with the given INITIAL_SIZE.
#define ROOT_DIR_SECTOR
Root directory file inode sector.
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.
void free_map_close(void)
Writes the free map to disk and closes the free map file.
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 ...
void inode_init(void)
Initializes the inode module.
int printf(const char *format,...)
Writes formatted output to the console.
int32_t off_t
An offset within a file.