feat: reformatted driver code and linkage. Some optimizations
This commit is contained in:
@@ -101,18 +101,6 @@ typedef struct {
|
||||
};
|
||||
} packed fat_directory_entry;
|
||||
|
||||
uint8_t fat_check_device(const block_device *device, uint8_t *first_sector);
|
||||
|
||||
block_dev_driver fat_driver = {
|
||||
.name = "fat",
|
||||
.check_device = fat_check_device,
|
||||
.free_device = NULL, // todo
|
||||
};
|
||||
|
||||
void fat_register_block_driver() {
|
||||
block_dev_register_driver(&fat_driver);
|
||||
}
|
||||
|
||||
void print_chars(char *chars, int amount) {
|
||||
for (int i = 0; i < amount; ++i) {
|
||||
if (chars[i] == 0) break;
|
||||
@@ -120,7 +108,7 @@ void print_chars(char *chars, int amount) {
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t fat_check_device(const block_device *device, uint8_t *first_sector) {
|
||||
uint8_t used fat_check_device(const block_device *device, uint8_t *first_sector) {
|
||||
fat_bpb bpb;
|
||||
memcpy((uint8_t *) &bpb, first_sector, sizeof(fat_bpb));
|
||||
if (bpb.bpb.sectors_per_fat == 0 || bpb.bpb.sectors_per_cluster == 0) {
|
||||
@@ -205,5 +193,10 @@ get_fat_table_value(uint8_t fat_type, const uint8_t *fat_table, uint32_t active_
|
||||
return result;
|
||||
}
|
||||
|
||||
BLOCK_DEV_DRIVER(
|
||||
.name = "fat",
|
||||
.check_device = fat_check_device,
|
||||
.free_device = NULL, // todo
|
||||
);
|
||||
|
||||
// steal validation code from here https://github.com/torvalds/linux/blob/fcadab740480e0e0e9fa9bd272acd409884d431a/fs/fat/inode.c#L1456
|
||||
Reference in New Issue
Block a user