Skip to content

[SUBISSUE #3] Implement File Transfer, Advisory Locking, Allocation, Sync, and xattr Boundaries #291

Todo

Description

@marcobuschini

Parent Issue / Epic

#281 (Epic #265)

Prerequisite Sub-Issue

#290

Atomic Deliverable & Implementation Details

Complete Phase 3 VFS syscalls for zero-copy/kernel-assisted transfer, file locking, preallocation, sync, and *xattr boundaries:

  • kernel/fs/Inode.hpp & kernel/fs/Vfs.{hpp,cpp}: Add advisory per-inode flock state (LOCK_SH, LOCK_EX, LOCK_NB, LOCK_UN) released automatically on final File close; add vfs_sync_all() / vfs_sync_sb().
  • kernel/syscalls/FileSyscalls.cpp & SyscallDispatcher.cpp:
    • Implement sys_flock (32), sys_fallocate (47, supporting default mode 0 and FALLOC_FL_KEEP_SIZE on tmpfs/ext2, returning -EOPNOTSUPP for unsupported punch/collapse modes), sys_sendfile (71), sys_splice (76, requiring at least one pipe endpoint), sys_sync (81), sys_syncfs (267), and sys_copy_file_range (285).
    • Wire *xattr syscalls (5–16: setxattr, lsetxattr, fsetxattr, getxattr, lgetxattr, fgetxattr, listxattr, llistxattr, flistxattr, removexattr, lremovexattr, fremovexattr) to validate FDs/paths (-EBADF/-ENOENT/-EFAULT) and return -EOPNOTSUPP (matching Linux filesystems without xattr support).
  • tests/host/ & kernel/shell/tests/: Add host ASan/UBSan and QEMU EL0 tests for sendfile, copy_file_range, splice, flock, fallocate, sync/syncfs, and *xattr.

Out of scope: mount/umount2 (Phase 5), inotify_* (Phase 6).

Acceptance Criteria & Edge Cases

  • sendfile and copy_file_range transfer data accurately across multi-page files, respect explicit off_in/off_out pointers, and leave open offsets untouched when explicit offsets are given
  • splice enforces at least one pipe FD (-EINVAL otherwise) and handles SPLICE_F_NONBLOCK cleanly
  • flock enforces shared/exclusive conflict (-EWOULDBLOCK under LOCK_NB) and releases locks automatically when the owning File closes
  • fallocate extends tmpfs/ext2 files without corrupting existing bytes and frees pages cleanly on unlink/truncate
  • 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