9#ifndef MAXOS_FILESYSTEM_EXT2_H
10#define MAXOS_FILESYSTEM_EXT2_H
14#include <common/macros.h>
21namespace MaxOS::filesystem::format::ext2 {
64 uint8_t filesystem_id[16];
65 uint8_t volume_name[16];
66 uint8_t last_mount_path[64];
71 uint8_t journal_id[16];
117 PREALLOCATE_DIRECTORY = 0x1,
118 AFS_SERVER_INODES = 0x2,
119 JOURNAL_ENABLED = 0x4,
120 ATTRIBUTES_EXTENDED = 0x8,
122 HASH_INDEXING = 0x20,
131 DIRECTORY_HAS_TYPE = 0x2,
132 MUST_REPLAY_JOURNAL = 0x4,
133 JOURNAL_DEVICE = 0x8,
141 SPARSE_SUPER_BLOCKS = 0x1,
143 BINARY_TREE_DIRECTORIES = 0x4,
164 } block_group_descriptor_t;
192 uint32_t block_pointers[12];
209 CHARACTER_DEVICE = 0x2000,
211 BLOCK_DEVICE = 0x6000,
213 SYMBOLIC_LINK = 0xA000,
254 FILE_COMPRESSION = 0x4,
256 FILE_IMMUTABLE = 0x10,
259 NO_LAST_ACCESS = 0x80,
260 HASH_INDEXED = 0x10000,
261 AFS_DIRECTORY = 0x20000,
262 JOURNAL_FILE_DATA = 0x40000,
326 void free_group_blocks(uint32_t block_group, uint32_t amount, uint32_t start);
329 void write_back_block_groups()
const;
330 void write_back_superblock();
377 void parse_indirect(uint32_t level, uint32_t block,
common::buffer_t* buffer);
378 void write_indirect(uint32_t level, uint32_t& block,
size_t& index);
389 [[nodiscard]]
size_t size()
const;
391 size_t grow(
size_t amount,
bool flush =
true);
429 void write_entries();
434 void remove_entry(
const string&
name,
bool is_directory,
bool clear =
true);
435 void rename_entry(
const string& old_name,
const string& new_name,
bool is_directory);
445 void rename_file(
const string& old_name,
const string& new_name)
final;
Wrapper class for a region of bytes in memor in an attempt to add some memory safety....
Stores the left, top, width and height of a rectangle.
Enables a resource to be used by only one instance at a time through locking and unlocking.
Generic Disk, handles the reading and writing of data to the hard drive.
Handles a group of files (directory)
string name()
Get the name of the directory.
Handles the disk operations and file system information.
Handles file operations and information.
string name()
Get the name of the file.
Defines drivers for the Programmable Interval Timer (PIT) and APIC Clock.
Defines a generic Disk driver for reading and writing data to disk drives.
InodePermissions
The permissions that an inode can have.
CreatorOS
The OS which created the filesystem.
struct PACKED MaxOS::filesystem::format::ext2::SuperBlock superblock_t
Alias for SuperBlock struct.
InodeType
The type of an inode.
InodeFlags
The flags that can be set on an inode.
InodePermissionsDefaults
The default permissions for files and directories.
ErrorOperation
What to do when an error occurs.
ReadOnlyFeatures
What features that are only required in read-only mode.
OptionalFeatures
What features that are optional are supported by this filesystem.
EntryType
The type of a directory entry.
struct PACKED MaxOS::filesystem::format::ext2::DirectoryEntry directory_entry_t
Alias for DirectoryEntry struct.
RequiredFeatures
What features that are required are supported by this filesystem.
struct PACKED MaxOS::filesystem::format::ext2::BlockGroupDescriptor block_group_descriptor_t
Alias for BlockGroupDescriptor struct.
struct PACKED MaxOS::filesystem::format::ext2::Inode inode_t
Alias for Inode struct.
FileSystemState
The state of the filesystem.
Defines a generic API for a file system, including classes for File, Directory, and FileSystem.
uint32_t lba_t
Logical Block Addressing type.
Defines classes for memory input and output operations of various bit widths (8, 16,...
Defines Spinlock and BlockingLock classes for thread synchronization.
An entry in a directory that points to a file or subdirectory (the name follows this struct)
uint32_t inode
The inode number this entry points to (0 = unused)
uint16_t size
The total size of this entry (including name)
uint8_t name_length
The length of the name.
uint8_t type
The type of the entry (see EntryType) (only if the high bit of the superblock's optional_features is ...