Skip to content

[SUBISSUE #2] Implement Extended Metadata and Namespace Operations (statx, statfs, fstatfs, symlinkat, linkat, mknodat) #290

Todo

Description

@marcobuschini

Parent Issue / Epic

#281 (Epic #265)

Prerequisite Sub-Issue

#289

Atomic Deliverable & Implementation Details

Add extended filesystem metadata queries and symlink/hardlink/node creation across VFS and filesystems:

  • kernel/uapi/fs.hpp: Define extern "C" LP64 linux_statx (256 bytes), linux_statx_timestamp (16 bytes), linux_statfs (120 bytes), STATX_* mask flags, and AT_EMPTY_PATH / AT_SYMLINK_FOLLOW constants with static_assert verification.
  • kernel/fs/Inode.hpp, Vfs.{hpp,cpp}, tmpfs/tmpfs.cpp, ext2/ext2.cpp, rootfs/rootfs.cpp, devfs/devfs.cpp:
    • Add symlink and link inode operations (tmpfs & ext2, returning -EROFS / -EPERM on read-only rootfs/devfs) and statfs superblock operation reporting filesystem magic (TMPFS_MAGIC, EXT2_SUPER_MAGIC, RAMFS_MAGIC), block size, and free/total blocks/inodes.
  • kernel/syscalls/FileSyscalls.cpp & SyscallDispatcher.cpp: Implement and dispatch sys_mknodat (33), sys_symlinkat (36), sys_linkat (37), sys_statfs (43), sys_fstatfs (44), and sys_statx (291).
  • tests/host/: Add Snitch ASan/UBSan tests across tmpfs, ext2, rootfs, and devfs.

Out of scope: sendfile/copy_file_range/splice/flock/fallocate/*xattr ([SUBISSUE #3]).

Acceptance Criteria & Edge Cases

  • sizeof(linux_statx) == 256 and sizeof(linux_statfs) == 120 verified by static_assert matching Linux AArch64 LP64 ABI
  • symlinkat + readlinkat and linkat (incrementing nlink, rejecting cross-mount -EXDEV and directory hardlinks -EPERM) work cleanly on tmpfs and ext2 with zero inode/dentry/PFA leaks
  • statx supports AT_EMPTY_PATH, AT_SYMLINK_NOFOLLOW, and populates stx_mask accurately
  • mknodat creates S_IFREG/S_IFIFO/S_IFSOCK nodes and rejects unsupported device types or collisions (-EEXIST, -EROFS)
  • 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