diff options
author | Anton Kling <anton@kling.gg> | 2023-11-13 19:20:36 +0100 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2023-11-13 19:23:58 +0100 |
commit | 1de1e8d02f392ed8bb061705d7717351bf3023bd (patch) | |
tree | 2f44b4e79d62225b27a8823bdfd9634ba5cb6a4e /kernel/fs/ext2.c | |
parent | 1966047921e2958469f9faac1bd1f56d1fc5587a (diff) |
Kernel: Add support for AHCI and make use of it with the current filesystem.
It will now also create a corresponding /dev/sd* device for each
detected SATA drive. The filesystem still writes using the ATA driver.
This should be fixed soon.
Diffstat (limited to 'kernel/fs/ext2.c')
-rw-r--r-- | kernel/fs/ext2.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/kernel/fs/ext2.c b/kernel/fs/ext2.c index 8092b23..17d9e11 100644 --- a/kernel/fs/ext2.c +++ b/kernel/fs/ext2.c @@ -14,6 +14,8 @@ u32 block_byte_size; u32 inode_size; u32 inodes_per_block; +vfs_fd_t *mount_fd = NULL; + #define BLOCK_SIZE (block_byte_size) void ext2_close(vfs_fd_t *fd) { @@ -55,7 +57,7 @@ void cached_read_block(u32 block, void *address, size_t size, size_t offset) { struct BLOCK_CACHE *c = &cache[free_found]; c->block_num = block; - read_lba(block * block_byte_size / 512, c->block, 1024, 0); + raw_vfs_pread(mount_fd, c->block, 1024, block * block_byte_size); cached_read_block(block, address, size, offset); } @@ -740,6 +742,11 @@ int ext2_create_file(const char *path, int mode) { } vfs_inode_t *ext2_mount(void) { + int fd = vfs_open("/dev/sda", O_RDWR, 0); + // TODO: Can this be done better? Maybe create a seperate function in + // the VFS? + mount_fd = get_current_task()->file_descriptors[fd]; + get_current_task()->file_descriptors[fd] = NULL; parse_superblock(); return vfs_create_inode(0 /*inode_num*/, 0 /*type*/, 0 /*has_data*/, 0 /*can_write*/, 0 /*is_open*/, @@ -751,7 +758,9 @@ vfs_inode_t *ext2_mount(void) { void parse_superblock(void) { superblock = ksbrk(2 * SECTOR_SIZE); - read_lba(EXT2_SUPERBLOCK_SECTOR, (void *)superblock, 2 * SECTOR_SIZE, 0); + raw_vfs_pread(mount_fd, superblock, 2 * SECTOR_SIZE, + EXT2_SUPERBLOCK_SECTOR * 512); + block_byte_size = 1024 << superblock->block_size; if (0xEF53 != superblock->ext2_signature) { |