feat: Vfs and Ext2 support. Code style/attribute improvements

Added VFS and Ext2 support.
Optimized attributes of methods to improve code highlighting.
Printf attribute, malloc attribute, etc.
This commit is contained in:
2021-10-06 21:45:15 +02:00
parent 073051c99e
commit 03f0ec6f88
24 changed files with 1322 additions and 90 deletions

View File

@@ -107,9 +107,26 @@ void print_chars(char *chars, int amount) {
}
}
uint8_t att_used fat_check_device(const block_device_t *device, uint8_t *first_sector) {
uint8_t att_used fat_check_device(const block_device_t *device) {
uint8_t *first_sector = malloc(512);
if (first_sector == NULL) {
printf("No mem\n");
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
}
uint8_t result = device->access(device, BLOCK_DEV_DIRECTION_READ, 0, 1, first_sector);
if (result != BLOCK_DEV_ACCESS_OK) {
printf("Could not access device\n");
free(first_sector);
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
}
if (first_sector[510] != 0x55 || first_sector[511] != 0xAA) {
printf("No boot signature\n");
free(first_sector);
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
}
fat_bpb bpb;
memcpy((uint8_t *) &bpb, first_sector, sizeof(fat_bpb));
free(first_sector);
if (bpb.bpb.sectors_per_fat == 0 || bpb.bpb.sectors_per_cluster == 0) {
printf("Definitely not FAT\n");
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;