-
Notifications
You must be signed in to change notification settings - Fork 0
/
fat32_lib.h
72 lines (65 loc) · 1.91 KB
/
fat32_lib.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
//
// Created by georgii on 24.02.2021.
//
#ifndef LAB1_FAT32_LIB_H
#define LAB1_FAT32_LIB_H
struct fat_BS {
u_int8_t boot_jmp[3];
u_char oem_name[8];
u_int16_t bytes_per_sector;
u_int8_t sectors_per_cluster;
u_int16_t reserved_sector_count;
u_int8_t table_count;
u_int16_t root_entry_count;
u_int16_t total_sectors_16;
u_int8_t media_type;
u_int16_t table_size_16;
u_int16_t sectors_per_track;
u_int16_t head_side_count;
u_int32_t hidden_sector_count;
u_int32_t total_sectors_32;
u_int32_t table_size_32;
u_int16_t extended_flags;
u_int16_t fat_version;
u_int32_t root_cluster;
u_int16_t fat_info;
u_int16_t backup_BS_sector;
u_int8_t reserved_0[12];
u_int8_t drive_number;
u_int8_t reserved_1;
u_int8_t boot_signature;
u_int32_t volume_id;
u_char volume_label[11];
u_char fat_type_label[8];
}__attribute__((packed));
struct fs_info {
u_int32_t lead_signature;
u_int8_t reserved_0[480];
u_int32_t another_signature;
u_int32_t last_free_cluster;
u_int32_t available;
u_int8_t reserved_1[12];
u_int32_t tail_signature;
}__attribute__((packed));
struct dir_value {
u_char *filename;
u_char type;
u_int32_t first_cluster;
u_int32_t size;
void *next;
};
struct partition_value {
int32_t device_fd;
u_int32_t cluster_size;
u_int32_t first_data_sector;
u_int32_t active_cluster;
struct fat_BS *fat_boot;
struct fs_info *fs_info;
};
u_int32_t read_file_cluster(struct partition_value *part, u_int32_t cluster, char *buf);
void destroy_dir_value(struct dir_value *dir_val);
struct dir_value *read_dir(u_int32_t first_cluster, struct partition_value *value);
int32_t change_dir(struct partition_value *value, const u_char *dir_name);
struct partition_value *open_partition(const char *partition);
void close_partition(struct partition_value *part);
#endif //LAB1_FAT32_LIB_H