-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfat.h
79 lines (71 loc) · 1.44 KB
/
fat.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
#pragma once
struct boot_record
{
char jump_code[3];
char oem_identifier[8];
short number_of_bytes_per_sector;
char number_of_sectors_per_cluster;
short number_of_reserved_sectors;
char number_of_file_allocation_tables;
short number_of_root_directory_entries;
short total_sectors;
char media_descriptor_type;
short number_of_sectors_per_fat;
short number_of_sectors_per_track;
short number_of_heads;
long number_of_hidden_sectors;
long large_sector_count;
char drive_number;
char reserved;
char signature;
long volume_id;
char volume_label[11];
char system_id[8];
} __attribute__((packed));
struct fat_directory
{
char filename[11];
char attributes;
char reserved;
char creation_time_sec_tens;
short time_created;
short date_created;
short last_accessed_date;
short cluster_hi;
short last_mod_time;
short last_mod_date;
short cluster_lo;
long file_size;
} __attribute__((packed));
union fat_time
{
struct
{
short seconds : 5;
short minutes : 6;
short hours : 5;
} __attribute__((packed));
short w;
};
union fat_date
{
struct
{
short day : 5;
short month : 4;
short year : 7;
} __attribute__((packed));
short w;
};
void fs_init(void);
void print_dir(const char *param);
void print_file(const char *filename);
void change_dir(const char *dirname);
struct fat_directory *find_starts_with(const char *);
struct file
{
int size;
char *data;
};
struct file file_open(const char *filename);
void file_close(struct file fi);