Skip to content

[SUBISSUE #3] Implement Dynamic Mount Management and Root Switching (mount, umount2, chroot, pivot_root) #297

Todo

Description

@marcobuschini

Parent Issue / Epic

#283 (Epic #265)

Prerequisite Sub-Issue

#290

Atomic Deliverable & Implementation Details

Expose VFS mount table management and per-process root directories to userspace:

  • kernel/uapi/fs.hpp: Add MS_RDONLY, MS_NOSUID, MS_NODEV, MS_NOEXEC, MS_REMOUNT, MS_BIND, MNT_FORCE, MNT_DETACH constants.
  • kernel/fs/Vfs.hpp & kernel/fs/Vfs.cpp: Support dynamic unmounting (vfs_umount, returning -EBUSY when open files/active mounts remain unless MNT_DETACH), remount flags (MS_REMOUNT), and per-process root-dentry resolution in vfs_namei().
  • kernel/process/Process.hpp & kernel/process/Process.cpp: Track per-process root path/dentry (inherited across fork/execve) so chroot scopes absolute path lookups cleanly.
  • kernel/syscalls/FileSyscalls.cpp & SyscallDispatcher.cpp: Implement and dispatch sys_umount2 (39), sys_mount (40, supporting tmpfs, devfs, ext2), sys_pivot_root (41), and sys_chroot (51).
  • tests/host/ & kernel/shell/tests/: Add host ASan/UBSan and QEMU tests for mounting/unmounting tmpfs & ext2, EBUSY checks, chroot isolation (.. clamped at chroot root), and zero VFS/PFA leaks.

Out of scope: per-process mount namespaces (CLONE_NEWNS / unshare — evaluated in Phase 6).

Acceptance Criteria & Edge Cases

  • mount mounts a new tmpfs (or ext2 block device) at an existing directory and umount2 cleanly reclaims all superblock/dentry/inode/PFA resources
  • umount2 returns -EBUSY when a file inside the mount is still open and -EINVAL for non-mountpoint paths
  • chroot updates the process root so /.. cannot escape the chroot boundary; pivot_root atomically swaps root and put_old mounts
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

subissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions