-
Notifications
You must be signed in to change notification settings - Fork 1
/
simplefs.h
69 lines (38 loc) · 1.33 KB
/
simplefs.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// @author:Zeynep Cankara
// @date: 16/05/2020
// @desc: Implementation of a simple file system (indexed allocation)
#define MODE_READ 0
#define MODE_APPEND 1
#define BLOCKSIZE 4096 // bytes
int create_format_vdisk(char *vdiskname, unsigned int m);
int sfs_mount(char *vdiskname);
int sfs_umount();
int sfs_create(char *filename);
int sfs_open(char *filename, int mode);
int sfs_close(int fd);
int sfs_getsize(int fd);
int sfs_read(int fd, void *buf, int n);
int sfs_append(int fd, void *buf, int n);
int sfs_delete(char *filename);
// helpers //
void init_superblock(int data_count);
void init_bitmap();
void init_FCB(int data_count);
void init_root_directory();
void clear_open_file_table();
int is_file_opened(int fd);
void init_file_block(int block_no);
int alloc_next_index_block_ptr(int index_block);
int fetch_next_index_block_ptr(int index_block);
int fetch_next_index_block_ptr_from_offset(int index_block, int index_block_offset);
void init_fcb_entry(int fcbIndex, int block, int offset);
// setters //
void set_superblock();
void set_directory_entry(int fd);
void set_bitmap_entry(int block_no, int bit);
// getters //
void get_superblock();
int get_index_block(int block_no, int block_offset);
int get_available_index_block_offset(int index_block);
int get_next_available_block();
int get_next_available_index_block();