PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
free-map.h File Reference
#include <stdbool.h>
#include <stddef.h>
#include "devices/block.h"
Include dependency graph for free-map.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void free_map_init (void)
 Initializes the free map. More...
 
void free_map_read (void)
 
void free_map_create (void)
 Creates a new free map file on disk and writes the free map to it. More...
 
void free_map_open (void)
 Opens the free map file and reads it from disk. More...
 
void free_map_close (void)
 Writes the free map to disk and closes the free map file. More...
 
bool free_map_allocate (size_t, block_sector_t *)
 Allocates CNT consecutive sectors from the free map and stores the first into *SECTORP. More...
 
void free_map_release (block_sector_t, size_t)
 filesys/free-map.h More...
 

Function Documentation

◆ free_map_allocate()

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.

Returns true if successful, false if not enough consecutive sectors were available or if the free_map file could not be written.

Definition at line 28 of file free-map.c.

References BITMAP_ERROR, bitmap_scan_and_flip(), bitmap_set_multiple(), free_map, free_map_file, and NULL.

Referenced by filesys_create(), and inode_create().

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

◆ free_map_close()

void free_map_close ( void  )

Writes the free map to disk and closes the free map file.

Definition at line 65 of file free-map.c.

References file_close(), and free_map_file.

Referenced by do_format(), and filesys_done().

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

◆ free_map_create()

void free_map_create ( void  )

Creates a new free map file on disk and writes the free map to it.

Definition at line 73 of file free-map.c.

References file_open(), free_map, free_map_file, FREE_MAP_SECTOR, inode_create(), inode_open(), NULL, and PANIC.

Referenced by do_format().

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

◆ free_map_init()

void free_map_init ( void  )

Initializes the free map.

Definition at line 13 of file free-map.c.

References bitmap_create(), bitmap_mark(), block_size(), free_map, FREE_MAP_SECTOR, fs_device, NULL, PANIC, and ROOT_DIR_SECTOR.

Referenced by filesys_init().

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

◆ free_map_open()

void free_map_open ( void  )

Opens the free map file and reads it from disk.

Definition at line 54 of file free-map.c.

References file_open(), free_map, free_map_file, FREE_MAP_SECTOR, inode_open(), NULL, and PANIC.

Referenced by filesys_init().

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

◆ free_map_read()

void free_map_read ( void  )

◆ free_map_release()

void free_map_release ( block_sector_t  sector,
size_t  cnt 
)

filesys/free-map.h

filesys/free-map.h

Definition at line 45 of file free-map.c.

References ASSERT, bitmap_all(), bitmap_set_multiple(), free_map, and free_map_file.

Referenced by filesys_create(), and inode_close().

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