]> Projects (at) Tadryanom (dot) Me - AdrOS.git/commit
vfs: add cwd check to umount to prevent filesystem in use
authorTulio A M Mendes <[email protected]>
Tue, 26 May 2026 02:42:57 +0000 (23:42 -0300)
committerTulio A M Mendes <[email protected]>
Wed, 3 Jun 2026 04:02:35 +0000 (01:02 -0300)
commit62a90ada9646dd30c3e306d66e5e7a48010ac302
tree98497a7905a80ec9d0df1f3dd9ad6f88e59bb6e5
parentf2973bc857311d667f3cfd3e41e93726cef3387a
vfs: add cwd check to umount to prevent filesystem in use

Added busy check in vfs_umount_nolock to reject unmount if any process
has its current working directory (cwd) within the mount being unmounted.

Implementation details:
- Checks current_process->cwd first (process executing umount)
- Iterates over ready_queue_head to check all other processes
- Uses path_is_mountpoint_prefix to determine if cwd is within mount
- Returns -EBUSY if any process has cwd in the mount
- Note: root directory check not implemented (would require vfs_getpath
  or storing root as path in process struct)

Also added test I20 (umount cwd) to fulltest.c:
- Mounts tmpfs to /tmp/mnt_cwd
- Changes cwd into the mount
- Verifies umount fails with -EBUSY
- Changes cwd back to /
- Verifies umount succeeds

Updated test harnesses (smoke_test.exp, test_battery.exp) to include
the new test pattern.

Test results:
- Smoke test: 124/124 PASS
- Zero regressions
src/kernel/fs.c
tests/smoke_test.exp
tests/test_battery.exp
user/cmds/fulltest/fulltest.c