Skip to content

feat(vfs): Add VFS abstraction layer and filesystem auto-probe mechanism (Assisted by AI)

某某某 requested to merge feat/ext4-vfs into main
  • Introduce include/fs/vfs.h: VFS filesystem type registry, super_block, and inode abstractions mapped from Rust trait FilesystemOps.
  • Introduce include/fs/ext4.h: EXT4 superblock physical layout with attribute((packed)) constraint and Magic Number 0xEF53 definition. References: nonix/lwext4_rust (BSD 2-Clause).
  • Introduce kernel/fs/vfs.c: VFS registration table, fs_probe engine, FAT32 probe (BPB sanity check), EXT4 probe (sector 2 magic check). References: T202510589995148-2209/crates/axfs-ng-vfs (MIT/MPL-2.0).
  • Introduce kernel/fs/ext4_stub.c: EXT4 mount stub that panics with a clear "not yet implemented" message after successful magic detection.
  • Refactor kernel/fs/fs.c: Replace hardcoded fat32_init() with dynamic filesystem probe chain: buf_init() -> vfs_init() -> register fs types -> buf_read(0) -> vfs_probe_filesystem() -> mount matched fs
  • Fix lock-safety: release vfs_lock before probe callbacks to avoid "sched locks" panic when buf_read -> virtio_disk_rw -> proc_sleep.
  • Fix print compatibility: use %x instead of %04X for custom printf.

QEMU verification: EXT4 test image no longer triggers the old "fat32_init: invalid sector size" panic. Instead, VFS intercepts, detects Magic 0xef53, and reports "EXT4 filesystem support is not implemented yet" as expected.

Merge request reports