swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 1 | #include <dri/fs/ext2/ext2.h> |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 2 | #include <dri/ata_pio/ata_pio.h> |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 3 | #include <kint.h> |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 4 | #include <log.h> |
| 5 | |
| 6 | struct ext2_superblock ext2_read_superblock() |
| 7 | { |
| 8 | uchar buffer[512 * 2]; |
| 9 | ata_pio_read_sectors(buffer, 2, 2); |
| 10 | |
| 11 | struct ext2_superblock *sb = (void *)(buffer); |
| 12 | return *sb; |
| 13 | } |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 14 | |
| 15 | void ext2_mount(struct fs_node *where) |
| 16 | { |
swissChili | 4418ca5 | 2021-06-14 17:36:00 -0700 | [diff] [blame] | 17 | struct ext2_superblock sb = ext2_read_superblock(); |
| 18 | |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 19 | kprintf(INFO "EXT2 magic = 0x%x\n", sb.signature); |
swissChili | ef829f3 | 2021-06-13 20:00:54 -0700 | [diff] [blame] | 20 | } |
swissChili | 9bd74de | 2021-06-15 20:30:48 -0700 | [diff] [blame] | 21 | |
| 22 | bool ext2_valid_filesystem() |
| 23 | { |
| 24 | struct ext2_superblock sb = ext2_read_superblock(); |
| 25 | |
| 26 | return sb.signature == EXT2_SIGNATURE; |
| 27 | } |