Skip to content

feat(fs): gave nodes identity and timestamps, added rename and symbolic links - #185

Merged
FlareCoding merged 13 commits into
masterfrom
pr/fs-node-identity
Sep 3, 2026
Merged

feat(fs): gave nodes identity and timestamps, added rename and symbolic links#185
FlareCoding merged 13 commits into
masterfrom
pr/fs-node-identity

Conversation

@FlareCoding

@FlareCoding FlareCoding commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary

  • Every file reported inode 0 and time 0, so compilers deduplicating include paths collapsed them into one and build tools could not tell what had changed, rename and symbolic links did not exist, and the initrd loader silently dropped the links it contained.
  • Nodes carry a lifetime-stable identity and access, modification, and change times, directories share one implementation, and rename, symbolic links, O_TRUNC, and O_EXCL behave as programs expect.
  • Path resolution follows links at constant stack depth, and scratch buffers moved off the privileged heap in line with the dynamic privilege model.

Note

Medium Risk
Large VFS surface area (symlink resolution, rename locking, open/create edge cases) can cause subtle path or concurrency bugs; changes are heavily tested in fs.test.cpp but touch core namespace behavior used by all file syscalls.

Overview
VFS nodes now expose real metadata and POSIX-style namespace operations so userland build tools and libc expectations (stat, rename, symlinks) work on ramfs/devfs.

Nodes get per-instance dev IDs, stable ino values, and nanosecond atime/mtime/ctime (via new clock::realtime_ns()). Base node::getattr/setattr and fsetattr replace duplicated device-node getattr overrides. Shared fs::dir_node centralizes lookup/readdir, bounded teardown, and rename/rmdir with a global tree lock and ordered directory locking to avoid deadlocks.

Path resolution follows symlinks (heap-spliced paths, SYMLOOP_MAX), supports LOOKUP_NOFOLLOW, and open with O_CREAT can create through dangling symlink chains. rename, symlink, O_TRUNC (writable regular files only), and O_EXCL are wired through VFS and Linux rename/renameat/symlink/symlinkat syscalls; stat/getdents report ino/dev/timestamps. CPIO initrd extraction now creates symlinks and restores mtime from the archive.

Clock drops per-arch cached boot time; boot_realtime_ns() and realtime_ns() are inlined off rtc::boot_unix_ns(). Syscall path scratch buffers move from kzalloc to uzalloc where appropriate.

Reviewed by Cursor Bugbot for commit 6dbcf7a. Bugbot is set up for automated code reviews on this repo. Configure here.

ramfs and devfs each carried their own copy of the child list, name
lookup, directory listing, and attribute reporting, so every directory
behavior had to be written twice and any new directory attribute could
land in one filesystem and silently miss the other. A common directory
base now owns the child list and the reads over it, while each
filesystem keeps only the mutations it chooses to allow, which leaves
ramfs writable and devfs populated solely by kernel drivers. The
non-recursive teardown that ramfs already used becomes the one
destructor, so nested directories in any filesystem unwind with
bounded stack depth.
cursor[bot]

This comment was marked as resolved.

cursor[bot]

This comment was marked as resolved.

Opening a link with O_CREAT resolved its final target by plain
directory lookup, which stops at a mount point instead of descending to
the filesystem mounted there, so a link to a mount point opened the
covered directory rather than the mounted root. The final step now
descends mounts like every other resolution path, through one shared
helper in place of three copies of the same loop, and losing a race to
create the target looks the new file up instead of failing.
@FlareCoding
FlareCoding merged commit b6b2dda into master Sep 3, 2026
17 checks passed
@FlareCoding
FlareCoding deleted the pr/fs-node-identity branch September 3, 2026 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant