[Krafton Jungle] PintOS 2.0.0
크래프톤 정글 PintOS
 
Loading...
Searching...
No Matches
free-map.c File Reference
#include "filesys/free-map.h"
#include <bitmap.h>
#include <debug.h>
#include "filesys/file.h"
#include "filesys/filesys.h"
#include "filesys/inode.h"
Include dependency graph for free-map.c:

Functions

void free_map_init (void)
 
bool free_map_allocate (size_t cnt, disk_sector_t *sectorp)
 
void free_map_release (disk_sector_t sector, size_t cnt)
 
void free_map_open (void)
 
void free_map_close (void)
 
void free_map_create (void)
 

Variables

static struct filefree_map_file
 
static struct bitmapfree_map
 

Function Documentation

◆ free_map_allocate()

bool free_map_allocate ( size_t  cnt,
disk_sector_t sectorp 
)
26 {
27 disk_sector_t sector = bitmap_scan_and_flip (free_map, 0, cnt, false);
28 if (sector != BITMAP_ERROR
30 && !bitmap_write (free_map, free_map_file)) {
31 bitmap_set_multiple (free_map, sector, cnt, false);
32 sector = BITMAP_ERROR;
33 }
34 if (sector != BITMAP_ERROR)
35 *sectorp = sector;
36 return sector != BITMAP_ERROR;
37}
size_t bitmap_scan_and_flip(struct bitmap *, size_t start, size_t cnt, bool)
Definition: bitmap.c:293
void bitmap_set_multiple(struct bitmap *, size_t start, size_t cnt, bool)
Definition: bitmap.c:199
#define BITMAP_ERROR
Definition: bitmap.h:36
uint32_t disk_sector_t
Definition: disk.h:12
static struct file * free_map_file
Definition: free-map.c:8
static struct bitmap * free_map
Definition: free-map.c:9
#define NULL
Definition: stddef.h:4
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_map_close()

void free_map_close ( void  )
59 {
61}
void file_close(struct file *file)
Definition: file.c:53
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_map_create()

void free_map_create ( void  )
66 {
67 /* Create inode. */
68 if (!inode_create (FREE_MAP_SECTOR, bitmap_file_size (free_map)))
69 PANIC ("free map creation failed");
70
71 /* Write bitmap to file. */
73 if (free_map_file == NULL)
74 PANIC ("can't open free map");
75 if (!bitmap_write (free_map, free_map_file))
76 PANIC ("can't write free map");
77}
#define PANIC(...)
Definition: debug.h:14
struct file * file_open(struct inode *inode)
Definition: file.c:17
#define FREE_MAP_SECTOR
Definition: filesys.h:8
struct inode * inode_open(disk_sector_t sector)
Definition: inode.c:103
bool inode_create(disk_sector_t sector, off_t length)
Definition: inode.c:68
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_map_init()

void free_map_init ( void  )
13 {
15 if (free_map == NULL)
16 PANIC ("bitmap creation failed--disk is too large");
19}
void bitmap_mark(struct bitmap *, size_t idx)
Definition: bitmap.c:143
struct bitmap * bitmap_create(size_t bit_cnt)
Definition: bitmap.c:73
disk_sector_t disk_size(struct disk *d)
Definition: disk.c:200
struct disk * filesys_disk
Definition: filesys.c:12
#define ROOT_DIR_SECTOR
Definition: filesys.h:9
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_map_open()

void free_map_open ( void  )
49 {
51 if (free_map_file == NULL)
52 PANIC ("can't open free map");
53 if (!bitmap_read (free_map, free_map_file))
54 PANIC ("can't read free map");
55}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_map_release()

void free_map_release ( disk_sector_t  sector,
size_t  cnt 
)
41 {
42 ASSERT (bitmap_all (free_map, sector, cnt));
43 bitmap_set_multiple (free_map, sector, cnt, false);
44 bitmap_write (free_map, free_map_file);
45}
bool bitmap_all(const struct bitmap *, size_t start, size_t cnt)
Definition: bitmap.c:260
#define ASSERT(CONDITION)
Definition: debug.h:30
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ free_map

struct bitmap* free_map
static

◆ free_map_file

struct file* free_map_file
static