-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilesystem.h
66 lines (47 loc) · 1.38 KB
/
filesystem.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
#ifndef FILESYSTEM_H
#define FILESYSTEM_H
#include <stdio.h>
#include <time.h>
#include <stdint.h>
#define BLOCK_SIZE 1024
#define NAME_LENGTH 16
#define FILES_IN_DIR 31
#define MAX_BLOCKS 255
/* Flags of attributes */
#define FIL 0x1
#define DIR 0x2
#define FREE 0
#define OCCUPIED(b) (0x3 & b)
typedef struct superBlock {
char name[6];
uint16_t size, block_size, n_blocks, empty_blocks, fat_offset, blocks_offset;
} SuperBlock;
typedef struct block {
uint8_t data[BLOCK_SIZE];
} Block;
typedef struct fatTable {
int16_t *tab;
} FATTable;
/* can be either file or directory */
typedef struct attributes {
char name[NAME_LENGTH];
time_t created;
uint16_t size;
uint8_t flags; /* file or dir or free */
uint8_t block_number;
} Attributes;
/* used to store information on a directory. It keeps one block */
typedef struct directory {
Attributes entries[FILES_IN_DIR];
uint16_t n_entries;
} Directory;
int create_disc(uint16_t size, char *name);
int show_fat(char *discName);
int make_directory(char *discName, char *path, char *name);
int add_file(char *disc_name, char *fromPath, char *toPath);
int get_file(char *disc_name, char *fromPath, char *name);
int show_directory(char *discName, char *path);
int remove_file(char *disc_name, char *path, char *name);
int stats(char *discName, char *path, char *name);
int remove_disc(char *discName);
#endif