]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
fs: fix mounted ext2/fat stat and dirent regressions
authorTulio A M Mendes <[email protected]>
Tue, 9 Jun 2026 01:24:40 +0000 (22:24 -0300)
committerTulio A M Mendes <[email protected]>
Tue, 9 Jun 2026 01:24:40 +0000 (22:24 -0300)
commitdcc9ea8f8be8e6758c3dd0208fd4d942a3493bc2
tree68875b56423d1920a0d8f6297c1618ded1c1f54b
parentc11ccfa7c28b6b1db3c30490916d7c711a56efed
fs: fix mounted ext2/fat stat and dirent regressions

Corrected:
- align kernel struct stat with the userspace ABI and update fulltest's local struct stat so stat/fstat copy the expected fields on mounted filesystems
- make getdents emit variable-length userspace dirent records with d_reclen and correct d_type values, and update ulibc readdir to consume them
- fix ext2 directory entry validation for exact-fit names and replace several 4KB on-stack buffers in ext2 inode/block/bitmap/write paths with heap-backed buffers to avoid stack-related crashes while listing and writing /disk
- populate sensible FAT mode/uid/gid defaults so ls -l reports sane metadata on FAT mounts
- preserve overlay root/initrd lifetime by keeping the initrd root registered separately and using a no-op close handler for the overlay root wrapper

Changed:
- add fulltest coverage for open('/disk') + getdents + close and for overlay root lifecycle after getdents/close/exec
- extend smoke_test.exp and test_battery.exp with the new /disk readdir and overlay root lifecycle expectations
- teach the minimal ulibc stdio formatter to accept a single 'l' length modifier so formats such as %lu work in ls -l output

TODO:
- add more targeted ext2 create/write regression coverage beyond the current fulltest/smoke battery if a smaller dedicated harness is introduced
- keep an eye on remaining direct getdents consumers, but the current tree passes make test and make test-battery in this state
include/stat.h
src/kernel/ext2.c
src/kernel/fat.c
src/kernel/init.c
src/kernel/overlayfs.c
src/kernel/syscall.c
tests/smoke_test.exp
tests/test_battery.exp
user/cmds/fulltest/fulltest.c
user/ulibc/src/dirent.c
user/ulibc/src/stdio.c