]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
vfs: block device layer, mount flags enforcement, refcount busy-checks, fstab options
authorTulio A M Mendes <[email protected]>
Mon, 25 May 2026 00:18:15 +0000 (21:18 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 04:02:35 +0000 (01:02 -0300)
commit731dd860f9ef410584a6b2b9eb99431d8bdf343f
treed99844b969bc2d0d67462fa9b368df56cd2ee374
parent9df0b36326b6d426c93733aa04df23bb7bff9980
vfs: block device layer, mount flags enforcement, refcount busy-checks, fstab options

Patch 1: Remove diskfs/persistfs source code from kernel
- Delete include/diskfs.h, include/persistfs.h
- Delete src/kernel/diskfs.c, src/kernel/persistfs.c
- Remove diskfs/persistfs auto-mount from init.c
- Remove diskfs/persistfs kconsole commands
- Remove diskfs.img creation from Makefile
- Remove diskfs/persistfs entries from rootfs/etc/fstab
- Update BUILD_GUIDE.md, README.md, docs/* to reflect removal

Patch 2: Clean fstab and Makefile
- Simplify rootfs/etc/fstab (remove diskfs/persistfs entries)
- Update fstab comments to reflect current mount layout
- Clean up Makefile (remove diskfs-related targets)
- Update documentation (BUILD_GUIDE.md, POSIX_ROADMAP.md)

Patch 3: Update fulltest, smoke_test, test_battery, statvfs for tmpfs ENOSYS
- fulltest.c: skip/rename/ftruncate tests now expect ENOSYS on tmpfs
  (tmpfs doesn't support these operations)
- statvfs.c: handle tmpfs fstype (report ~64MB blocks, zero free)
- smoke_test.exp: update patterns for tmpfs ENOSYS handling
- test_battery.exp: update patterns for tmpfs ENOSYS handling
- docs/TESTING_PLAN.md, SYSCALL_TEST_COVERAGE.md: update counts

Patch 4: Raw ATA block device test
- Add D7b test in fulltest that reads /dev/hda MBR sector (512 bytes)
- Non-fatal when /dev/hda absent (diskless boot)
- Add test patterns to smoke_test.exp and test_battery.exp

Patch 5: Generic block device layer
- New include/blockdev.h: block_device_t with ops->read/write,
  blockdev_register/find/by_id API, inline blockdev_read/write
- New src/kernel/blockdev.c: registry + ATA block device ops adapter
- Refactor fat.c: replace ata_pio_read28/write28 with blockdev_read/write
- Refactor ext2.c: same pattern via g_ext2.bdev
- init.c: call blockdev_register_ata() before mounting disk filesystems

Patch 6: Enforce mount flags (MS_RDONLY, MS_NOEXEC, MS_NODEV, MS_NOSUID)
- Add MS_* constants to fs.h (match userspace sys/mount.h values)
- Add vfs_mount_flags(), vfs_node_mount_flags(), vfs_find_mount_root()
- Add mount_root field to struct file (set on open, used for flag checks)
- syscall_open_impl: reject O_WRONLY/O_RDWR on MS_RDONLY (-EROFS),
  reject device open on MS_NODEV (-EACCES)
- syscall_write_impl: reject writes on MS_RDONLY mounts (-EROFS)
- syscall_execve_impl: reject exec on MS_NOEXEC mounts (-EPERM)
- Use MS_REMOUNT constant instead of hardcoded 0x20

Patch 7: Mount refcount and umount busy checks
- Add refcount field to vfs_mount struct
- vfs_umount_nolock rejects umount if refcount > 0 (-EBUSY)
- Add vfs_mount_ref/unref helpers, called on file open/close
- Fix uninitialized mount_root in console file setup (arch_platform.c)

Patch 8: Improve fstab options parsing and /proc/mounts
- init.c fstab parser now parses options field (ro,nosuid,nodev,noexec)
  and converts to MS_* mount flags
- vfs_mounts_read uses named MS_* constants instead of hardcoded bits

Tests: smoke 116/116, battery 142/142, host 111/111 — zero regressions
29 files changed:
BUILD_GUIDE.md
Makefile
README.md
docs/POSIX_ROADMAP.md
docs/SUPPLEMENTARY_ANALYSIS.md
docs/SYSCALL_TEST_COVERAGE.md
docs/TESTING_PLAN.md
include/blockdev.h [new file with mode: 0644]
include/diskfs.h [deleted file]
include/fs.h
include/kernel/init.h
include/persistfs.h [deleted file]
include/process.h
rootfs/etc/fstab
src/arch/x86/arch_platform.c
src/kernel/blockdev.c [new file with mode: 0644]
src/kernel/diskfs.c [deleted file]
src/kernel/ext2.c
src/kernel/fat.c
src/kernel/fs.c
src/kernel/init.c
src/kernel/kconsole.c
src/kernel/persistfs.c [deleted file]
src/kernel/syscall.c
tests/smoke_test.exp
tests/test_battery.exp
user/cmds/fulltest/fulltest.c
user/cmds/init/init.c
user/ulibc/src/statvfs.c