blob: 4205c4b0a1b270aea5eb2c3e952b93e884a28f8c [file] [log] [blame]
swissChilief829f32021-06-13 20:00:54 -07001#pragma once
2
3#include <vfs.h>
4
5struct ext2_superblock
6{
7 // Total number of inodes
8 uint total_inodes;
9 // Total number of blocks
10 uint total_blocks;
11 // Number of blocks reserved for superuser
12 uint blocks_reserved_for_superuser;
13 // Number of unallocated blocks
14 uint unallocated_blocks;
15 // Number of unallocated inodes
16 uint unallocated_inodes;
17 // Block number containing the superblock
18 uint superblock_block_number;
19 // the number to shift 1024 to the left by to get the block size
20 uint block_size_shift;
21 // the number to shift 1024 to the left by to get the fragment size
22 uint fragment_size_shift;
23 // Number of blocks in one block group
24 uint blocks_per_block_group;
25 // Number of fragments in one block group
26 uint fragments_per_block_group;
27 // Number of inodse in one block group
28 uint inodes_per_block_group;
29 // UNIX time of last mount
30 uint last_mount_time;
31 // UNIX time of last write
32 uint last_write_time;
33 // Number of mounts since last consistency check
34 ushort mounts_since_last_fsck;
35 // Number of mounts allowed between consistency checks
36 ushort mounts_allowed_before_fsck;
37 // EXT2 signature, should be 0xef53
38 ushort signature;
39 // File system state, see enum ext2_fs_state
40 ushort state;
41 // What to do in case of an error, see enum ext2_error_case
42 ushort error_case;
43 // Minor portion of version
44 ushort version_minor;
45 // UNIX time of last consistency check
46 uint last_fsck_time;
47 // Max time between consistency checks
48 uint fsck_time_interval;
49 // Operating system ID of creator
50 uint creator_os_id;
51 // Major portion of version
52 uint version_major;
53 // User ID that can use reserved blocks
54 ushort reserved_blocks_uid;
55 // Group ID that can use reserved blocks
56 ushort reserved_blocks_gid;
57};
58
59enum ext2_fs_state
60{
61 EXT2_STATE_CLEAN = 1,
62 EXT2_STATE_ERRORS = 2,
63};
64
65enum ext2_error_case
66{
67 EXT2_ERROR_IGNORE = 1,
68 EXT2_ERROR_REMOUNT = 2,
69 EXT2_ERROR_KPANIC = 3,
70};
71
72enum ext2_os_id
73{
74 EXT2_OS_LINUX = 0,
75 EXT2_OS_HURD,
76 EXT2_OS_MASIX,
77 EXT2_OS_FREEBSD,
78 EXT2_OS_OTHER_BSD,
79};
80
swissChili9bd74de2021-06-15 20:30:48 -070081#define EXT2_SIGNATURE 0xef53
82
swissChili4418ca52021-06-14 17:36:00 -070083struct ext2_superblock ext2_read_superblock();
swissChilief829f32021-06-13 20:00:54 -070084void ext2_mount(struct fs_node *where);
swissChili9bd74de2021-06-15 20:30:48 -070085bool ext2_valid_filesystem();