PKUOS - Pintos
Pintos source browser for PKU Operating System course
Macros | Functions | Variables
filesys.h File Reference
#include <stdbool.h>
#include "filesys/off_t.h"
Include dependency graph for filesys.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FREE_MAP_SECTOR   0
 Sectors of system file inodes. More...
 
#define ROOT_DIR_SECTOR   1
 Root directory file inode sector. More...
 

Functions

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 filefilesys_open (const char *name)
 Opens the file with the given NAME. More...
 
bool filesys_remove (const char *name)
 filesys/filesys.h More...
 

Variables

struct blockfs_device
 Block device that contains the file system. More...
 

Macro Definition Documentation

◆ FREE_MAP_SECTOR

#define FREE_MAP_SECTOR   0

Sectors of system file inodes.

Free map file inode sector.

Definition at line 8 of file filesys.h.

◆ ROOT_DIR_SECTOR

#define ROOT_DIR_SECTOR   1

Root directory file inode sector.

Definition at line 9 of file filesys.h.

Function Documentation

◆ filesys_create()

bool filesys_create ( const char *  name,
off_t  initial_size 
)

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filesys_done()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filesys_init()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filesys_open()

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().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ filesys_remove()

bool filesys_remove ( const char *  name)

filesys/filesys.h

filesys/filesys.h

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().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ fs_device

struct block* fs_device

Block device that contains the file system.

Definition at line 12 of file filesys.h.