Skip to content

Commit cea816c

Browse files
committed
mount more ext4fs
1 parent f6bce9a commit cea816c

3 files changed

Lines changed: 13 additions & 9 deletions

File tree

modules/axfs/src/dev.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ impl Partition {
123123
(self.end_lba - self.start_lba + 1) * BLOCK_SIZE as u64
124124
}
125125

126-
/// Get the position of the cursor.
126+
/// Get position of cursor.
127127
pub fn position(&self) -> u64 {
128128
self.position
129129
}
@@ -133,6 +133,11 @@ impl Partition {
133133
self.position = pos.min(self.size());
134134
}
135135

136+
/// Get the starting LBA of the partition.
137+
pub fn start_lba(&self) -> u64 {
138+
self.start_lba
139+
}
140+
136141
/// Read within one block, returns the number of bytes read.
137142
pub fn read_one(&mut self, buf: &mut [u8]) -> DevResult<usize> {
138143
if self.position >= self.size() {

modules/axfs/src/fs/ext4fs.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use crate::alloc::string::{String, ToString};
2+
23
use alloc::sync::Arc;
4+
use alloc::format;
35
pub use axdriver_block::DevError;
46
use axerrno::AxError;
57
use axfs_vfs::{
@@ -59,7 +61,11 @@ impl Ext4FileSystem {
5961
partition.size(),
6062
partition.position()
6163
);
62-
let inner = Ext4BlockWrapper::<Partition>::new(partition)
64+
// Use a unique device name for each partition to avoid conflicts
65+
// Use the start LBA as a unique identifier
66+
let start_lba = partition.start_lba();
67+
let device_name = format!("device_{}", start_lba);
68+
let inner = Ext4BlockWrapper::<Partition>::new_with_name(partition, &device_name)
6369
.expect("failed to initialize EXT4 filesystem on partition");
6470
let root = Arc::new(FileWrapper::new("/", InodeTypes::EXT4_DE_DIR));
6571
Ext4FileSystemPartition { inner, root }

modules/axfs/src/partition.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,6 @@ fn detect_filesystem_type(disk: &mut Disk, start_lba: u64) -> Option<FilesystemT
286286
// Restore position
287287
disk.set_position(original_position);
288288

289-
// Debug: print first bytes of boot sector
290-
debug!(
291-
"Boot sector at LBA {}: first 64 bytes: {:?}",
292-
start_lba,
293-
&boot_sector[..64]
294-
);
295-
296289
// Check for FAT filesystem
297290
if is_fat_filesystem(&boot_sector) {
298291
debug!("Detected FAT filesystem at LBA {}", start_lba);

0 commit comments

Comments
 (0)