PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
#include "filesys/filesys.h"
#include <debug.h>
#include <stdio.h>
#include <string.h>
#include "filesys/file.h"
#include "filesys/free-map.h"
#include "filesys/inode.h"
#include "filesys/directory.h"
Go to the source code of this file.
Functions | |
static void | do_format (void) |
Formats the file system. More... | |
void | filesys_init (bool format) |
Initializes the file system module. More... | |
void | filesys_done (void) |
Shuts down the file system module, writing any unwritten data to disk. More... | |
bool | filesys_create (const char *name, off_t initial_size) |
Creates a file named NAME with the given INITIAL_SIZE. More... | |
struct file * | filesys_open (const char *name) |
Opens the file with the given NAME. More... | |
bool | filesys_remove (const char *name) |
Deletes the file named NAME. More... | |
Variables | |
struct block * | fs_device |
Partition that contains the file system. More... | |
|
static |
Formats the file system.
Definition at line 95 of file filesys.c.
References dir_create(), free_map_close(), free_map_create(), PANIC, printf(), and ROOT_DIR_SECTOR.
Referenced by filesys_init().
Creates a file named NAME with the given INITIAL_SIZE.
Returns true if successful, false otherwise. Fails if a file named NAME already exists, or if internal memory allocation fails.
Definition at line 46 of file filesys.c.
References dir_add(), dir_close(), dir_open_root(), free_map_allocate(), free_map_release(), inode_create(), name, and NULL.
Referenced by fsutil_extract().
void filesys_done | ( | void | ) |
Shuts down the file system module, writing any unwritten data to disk.
Definition at line 36 of file filesys.c.
References free_map_close().
Referenced by shutdown_power_off().
void filesys_init | ( | bool | format | ) |
Initializes the file system module.
If FORMAT is true, reformats the file system.
Definition at line 18 of file filesys.c.
References BLOCK_FILESYS, block_get_role(), do_format(), free_map_init(), free_map_open(), fs_device, inode_init(), NULL, and PANIC.
Referenced by pintos_init().
struct file * filesys_open | ( | const char * | name | ) |
Opens the file with the given NAME.
Returns the new file if successful or a null pointer otherwise. Fails if no file named NAME exists, or if an internal memory allocation fails.
Definition at line 67 of file filesys.c.
References dir_close(), dir_lookup(), dir_open_root(), file_open(), name, and NULL.
Referenced by fsutil_append(), fsutil_cat(), fsutil_extract(), and load().
bool filesys_remove | ( | const char * | name | ) |
Deletes the file named NAME.
Returns true if successful, false on failure. Fails if no file named NAME exists, or if an internal memory allocation fails.
Definition at line 84 of file filesys.c.
References dir_close(), dir_open_root(), dir_remove(), name, and NULL.
Referenced by fsutil_rm().
struct block* fs_device |
Partition that contains the file system.
Definition at line 11 of file filesys.c.
Referenced by filesys_init(), free_map_init(), inode_create(), inode_open(), inode_read_at(), and inode_write_at().