]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commitdiff
ext2: add ext2_mount_partition helper (Etapa 5)
authorTulio A M Mendes <[email protected]>
Tue, 26 May 2026 04:05:55 +0000 (01:05 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 04:02:35 +0000 (01:02 -0300)
- Added ext2_mount_partition(partition_t*) helper function
- Extracts parent block device and start_lba from partition
- Calls ext2_mount with extracted parameters
- Maintains compatibility with existing ext2_mount signature
- Tests: 124/124 PASS

include/ext2.h
src/kernel/ext2.c

index 04098a997d147b29705a5e07f1a1b91ce55bc591..29d2235242c95f2566ea5caf5c9b87b6578f2b16 100644 (file)
@@ -14,6 +14,7 @@
 #include "blockdev.h"
 #include <stdint.h>
 
+struct partition;
 struct ext2_group_desc;
 
 /* Per-mount filesystem state */
@@ -37,6 +38,9 @@ struct ext2_mount {
  * LBA offset.  Returns a mount result with root node and superblock, or {NULL, NULL} on failure. */
 vfs_mount_result_t ext2_mount(block_device_t* bdev, uint32_t partition_lba);
 
+/* Mount ext2 filesystem from a partition (uses partition's parent and start_lba) */
+vfs_mount_result_t ext2_mount_partition(struct partition* part);
+
 /* Unmount an ext2 filesystem and free its resources */
 void ext2_umount(struct ext2_mount* em);
 
index 677ce5d54c11c74fdb709250bcf18e4aa1563253..371ff64dcf1c8220a10160bb3f58c94f572a1a7d 100644 (file)
@@ -10,6 +10,7 @@
 #include "ext2.h"
 #include "fs.h"
 #include "blockdev.h"
+#include "partition.h"
 #include "heap.h"
 #include "utils.h"
 #include "console.h"
@@ -1571,3 +1572,11 @@ void ext2_umount(struct ext2_mount* em) {
         kfree(em);
     }
 }
+
+vfs_mount_result_t ext2_mount_partition(struct partition* part) {
+    if (!part || !part->parent) {
+        vfs_mount_result_t result = {NULL, NULL};
+        return result;
+    }
+    return ext2_mount(part->parent, part->start_lba);
+}