-
Notifications
You must be signed in to change notification settings - Fork 12
/
sfs_header.h
86 lines (55 loc) · 1.34 KB
/
sfs_header.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#ifndef min
#define min( a, b ) ( ((a) < (b)) ? (a) : (b) )
#endif
#ifndef SFS_API_HEADER
#define SFS_API_HEADER
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#define NB_BLOCK 4096
#define MAX_DISK NB_BLOCK
#define FAT_SIZE NB_BLOCK
#define NB_FILES 512
#define MAX_FILE NB_FILES
#define EMPTY -69
typedef struct FileAccessStatus {
int opened;
int wr_ptr;
int rd_ptr;
} FileAccessStatus;
typedef struct FileDescriptor {
char filename[32];
int fat_index;
time_t timestamp;
int size;
FileAccessStatus fas;
} FileDescriptor;
typedef struct DirectoryDescriptor {
FileDescriptor table[MAX_FILE];
int count;
} DirectoryDescriptor;
typedef struct fat_node {
size_t db_index;
int next;
int free;
} fat_node;
typedef struct FileAllocationTable {
fat_node table[MAX_DISK];
int count;
} FileAllocationTable;
typedef struct freeblocklist {
int list[MAX_DISK];
} freeblocklist;
typedef union DiskBlock {
DirectoryDescriptor dd;
FileAllocationTable fat;
freeblocklist fbl;
} DiskBlock;
void mksfs(int fresh);
void sfs_ls();
int sfs_open(char * name);
int sfs_close(int fileID);
int sfs_write(int fileID, char * buf, int length);
int sfs_read(int fileID, char * buf, int length);
#endif