feat: implemented errno, strtol. Started ustar. Reformatted headers and
code. Added some self-tests. Started prepwork for vfs.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <myke/fs/mbr.h>
|
||||
#include <myke/drivers/ide.h>
|
||||
#include <myke/drivers/pci/ide.h>
|
||||
#include <myke/fs/blockdev.h>
|
||||
#include <myke/attributes.h>
|
||||
|
||||
@@ -33,12 +33,12 @@ typedef struct {
|
||||
} packed mbr_table;
|
||||
|
||||
typedef struct {
|
||||
const block_device *device;
|
||||
const block_device_t *device;
|
||||
uint32_t start_lba;
|
||||
} mbr_block_driver_info;
|
||||
|
||||
uint8_t
|
||||
mbr_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
mbr_block_dev_access(const block_device_t *device, uint8_t direction, uint32_t lba, uint8_t sectors, void *target) {
|
||||
if (!device->flags.present || lba > device->num_lba) {
|
||||
return BLOCK_DEV_ACCESS_ERR;
|
||||
}
|
||||
@@ -52,7 +52,7 @@ mbr_block_dev_access(const block_device *device, uint8_t direction, uint32_t lba
|
||||
return info->device->access(info->device, direction, actual_lba, sectors, target);
|
||||
}
|
||||
|
||||
uint8_t used mbr_check_device(const block_device *device, uint8_t *first_sector) {
|
||||
uint8_t used mbr_check_device(const block_device_t *device, uint8_t *first_sector) {
|
||||
mbr_table table;
|
||||
memcpy((uint8_t *) &table, first_sector + (device->block_size - sizeof(mbr_table)), sizeof(mbr_table));
|
||||
if (table.signature[0] != 0x55 && table.signature[1] != 0xAA) { // AA 55 but in little endian
|
||||
@@ -69,14 +69,16 @@ uint8_t used mbr_check_device(const block_device *device, uint8_t *first_sector)
|
||||
}
|
||||
}
|
||||
|
||||
int num_parts = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
if (table.entries[i].system_id == 0) continue;
|
||||
num_parts += 1;
|
||||
|
||||
mbr_block_driver_info *info = malloc(sizeof(mbr_block_driver_info));
|
||||
info->device = device;
|
||||
info->start_lba = table.entries[i].start_lba;
|
||||
|
||||
block_device logical_device = {
|
||||
block_device_t logical_device = {
|
||||
.flags.present = 1,
|
||||
|
||||
.num_lba = table.entries[i].num_lbas,
|
||||
@@ -88,7 +90,10 @@ uint8_t used mbr_check_device(const block_device *device, uint8_t *first_sector)
|
||||
sprintf(logical_device.identifier, "%sp%d", device->identifier, i);
|
||||
|
||||
block_dev_register(&logical_device);
|
||||
}
|
||||
|
||||
if (num_parts == 0) {
|
||||
return BLOCK_DEV_DRIVER_CHECK_NO_MATCH;
|
||||
}
|
||||
|
||||
return BLOCK_DEV_DRIVER_CHECK_OK;
|
||||
@@ -104,7 +109,7 @@ void mbr_read_from_ide(uint8_t ide_drive) {
|
||||
|
||||
BLOCK_DEV_DRIVER(200) = {
|
||||
.name = "mbr",
|
||||
.flags.root_only = 1,
|
||||
.flags.partitioning = 1,
|
||||
.check_device = mbr_check_device,
|
||||
.free_device = NULL, // todo
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user