Skip to content

Commit 474147a

Browse files
feat(fs/iso9660): implement ISO 9660 filesystem with extensions and VFS integration
1 parent 465b612 commit 474147a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1631
-1
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# ISO 9660 Base Structures
2+
3+
Implemented the core data structures and constants for the ISO 9660 filesystem.
4+
5+
## Changes
6+
- Created `Include/Kernel/Fs/ISO9660/` directory.
7+
- Added `iso9660_constants.h` with enums and general constants.
8+
- Added `volume_descriptor_header.h`.
9+
- Added `primary_volume_descriptor.h` with all PVD fields.
10+
- Added `directory_record.h` with fixed-size directory record structure.
11+
- Added `path_table_entry.h`.
12+
- Added helper structures for ISO 9660 specific types:
13+
- `iso9660_both_endian_uint16.h`
14+
- `iso9660_both_endian_uint32.h`
15+
- `iso9660_recording_time.h`
16+
- `iso9660_volume_time.h`
17+
- Implemented `Iso9660Volume` class (`iso9660_volume.h`/`.cpp`) for PVD/VDS parsing.
18+
- Implemented `Iso9660Parser` class (`iso9660_parser.h`/`.cpp`) for directory record parsing.
19+
- Implemented SUSP (System Use Sharing Protocol) v1.12:
20+
- Added `susp_entry_header.h`, `susp_continuation_area.h`, `susp_extension_reference.h`, `susp_extension_selector.h`.
21+
- Added `SuspParser` (`susp_parser.h`/`.cpp`) with support for continuation areas ('CE' entries).
22+
- Implemented Rock Ridge Interchange Protocol (RRIP) v1.12:
23+
- Added `rock_ridge_posix_file_attributes.h`.
24+
- Added `RockRidgeParser` (`rock_ridge_parser.h`/`.cpp`) for POSIX metadata ('PX') and long names ('NM').
25+
- Implemented Joliet Unicode Extension:
26+
- Added `JolietParser` (`joliet_parser.h`/`.cpp`) for UTF-16 to UTF-8 filename conversion.
27+
- Implemented El Torito Bootable CD Extension:
28+
- Added `el_torito_boot_record.h`, `el_torito_validation_entry.h`, `el_torito_default_entry.h`.
29+
- Added `ElToritoParser` (`el_torito_parser.h`/`.cpp`) for boot catalog parsing.
30+
31+
## Architectural Compliance
32+
- Adhered to the "ONE STRUCT/CLASS PER FILE" rule.
33+
- Used `[[gnu::packed]]` for all filesystem structures to ensure correct hardware mapping.
34+
- Placed all files in the appropriate domain-based directory structure.
35+
- Used `fk::core::Result` and `TRY` macro for robust error handling.
36+
- Followed PascalCase for classes and snake_case for files.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#pragma once
2+
3+
#include <LibFK/Types/types.h>
4+
#include <Kernel/Fs/ISO9660/iso9660_both_endian_uint16.h>
5+
#include <Kernel/Fs/ISO9660/iso9660_both_endian_uint32.h>
6+
#include <Kernel/Fs/ISO9660/iso9660_recording_time.h>
7+
8+
namespace fkernel {
9+
10+
struct [[gnu::packed]] Iso9660DirectoryRecord {
11+
uint8_t length;
12+
uint8_t extended_attribute_length;
13+
Iso9660BothEndianUint32 extent_location;
14+
Iso9660BothEndianUint32 data_length;
15+
Iso9660RecordingTime recording_time;
16+
uint8_t flags;
17+
uint8_t file_unit_size;
18+
uint8_t interleave_gap_size;
19+
Iso9660BothEndianUint16 volume_sequence_number;
20+
uint8_t identifier_length;
21+
// Followed by char identifier[identifier_length]
22+
// Followed by padding byte if identifier_length is even
23+
// Followed by System Use Area
24+
};
25+
26+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#pragma once
2+
3+
#include <Kernel/Fs/ISO9660/volume_descriptor_header.h>
4+
5+
namespace fkernel {
6+
7+
struct [[gnu::packed]] Iso9660ElToritoBootRecord {
8+
Iso9660VolumeDescriptorHeader header;
9+
char boot_system_identifier[32];
10+
char boot_identifier[32];
11+
uint32_t boot_catalog_pointer;
12+
uint8_t reserved[1973];
13+
};
14+
15+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#pragma once
2+
3+
#include <LibFK/Types/types.h>
4+
5+
namespace fkernel {
6+
7+
struct [[gnu::packed]] Iso9660ElToritoDefaultEntry {
8+
uint8_t boot_indicator;
9+
uint8_t boot_media_type;
10+
uint16_t load_segment;
11+
uint8_t system_type;
12+
uint8_t reserved1;
13+
uint16_t sector_count;
14+
uint32_t load_rba;
15+
uint8_t reserved2[20];
16+
};
17+
18+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#pragma once
2+
3+
#include <Kernel/Driver/Storage/storage_device.h>
4+
#include <Kernel/Fs/ISO9660/el_torito_boot_record.h>
5+
#include <Kernel/Fs/ISO9660/el_torito_default_entry.h>
6+
#include <LibFK/Core/Result.h>
7+
8+
namespace fkernel {
9+
10+
class ElToritoParser {
11+
public:
12+
explicit ElToritoParser(StorageDevice& device);
13+
~ElToritoParser() = default;
14+
15+
fk::core::Result<Iso9660ElToritoDefaultEntry, fk::core::Error> find_default_boot_entry();
16+
17+
private:
18+
StorageDevice& m_device;
19+
20+
fk::core::Result<void, fk::core::Error> validate_catalog(uint32_t catalog_lba);
21+
};
22+
23+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <LibFK/Types/types.h>
4+
5+
namespace fkernel {
6+
7+
struct [[gnu::packed]] Iso9660ElToritoValidationEntry {
8+
uint8_t header_id;
9+
uint8_t platform_id;
10+
uint16_t reserved;
11+
char id_string[24];
12+
uint16_t checksum;
13+
uint8_t key_55;
14+
uint8_t key_AA;
15+
};
16+
17+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <LibFK/Types/types.h>
4+
5+
namespace fkernel {
6+
7+
struct [[gnu::packed]] Iso9660BothEndianUint16 {
8+
uint16_t little_endian;
9+
uint16_t big_endian;
10+
};
11+
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#pragma once
2+
3+
#include <LibFK/Types/types.h>
4+
5+
namespace fkernel {
6+
7+
struct [[gnu::packed]] Iso9660BothEndianUint32 {
8+
uint32_t little_endian;
9+
uint32_t big_endian;
10+
};
11+
12+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#pragma once
2+
3+
#include <LibFK/Types/types.h>
4+
5+
namespace fkernel {
6+
7+
enum class Iso9660VolumeDescriptorType : uint8_t {
8+
BootRecord = 0,
9+
PrimaryVolumeDescriptor = 1,
10+
SupplementaryVolumeDescriptor = 2,
11+
VolumePartitionDescriptor = 3,
12+
VolumeDescriptorSetTerminator = 255
13+
};
14+
15+
static constexpr uint32_t ISO9660_SECTOR_SIZE = 2048;
16+
static constexpr uint32_t ISO9660_SYSTEM_AREA_SECTORS = 16;
17+
static constexpr const char* ISO9660_IDENTIFIER = "CD001";
18+
19+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#pragma once
2+
3+
#include <Kernel/Fs/Vfs/node.h>
4+
#include <LibFK/Memory/ref_ptr.h>
5+
6+
namespace fkernel {
7+
8+
class Iso9660FileSystem;
9+
10+
class Iso9660DirNode final : public Node {
11+
public:
12+
Iso9660DirNode(fk::RefPtr<Iso9660FileSystem> fs, uint32_t extent_location, uint32_t data_length);
13+
virtual ~Iso9660DirNode() override = default;
14+
15+
virtual fk::core::Result<size_t, fk::core::Error> read(uint64_t offset, size_t size, uint8_t *buffer) override;
16+
virtual fk::core::Result<size_t, fk::core::Error> write(uint64_t offset, size_t size, const uint8_t *buffer) override;
17+
virtual size_t size() const override { return m_data_length; }
18+
virtual bool is_directory() const override { return true; }
19+
20+
virtual fk::core::Result<void, fk::core::Error> list_dir(fk::containers::Vector<DirectoryEntry>& entries) override;
21+
virtual fk::core::Result<fk::RefPtr<Node>, fk::core::Error> lookup(const fk::text::Utf8String& name) override;
22+
23+
private:
24+
fk::RefPtr<Iso9660FileSystem> m_fs;
25+
uint32_t m_extent_location;
26+
uint32_t m_data_length;
27+
};
28+
29+
}

0 commit comments

Comments
 (0)