feat(fs): gave nodes identity and timestamps, added rename and symbolic links - #185
Merged
Conversation
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.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
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.cppbut 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
devIDs, stableinovalues, and nanosecond atime/mtime/ctime (via newclock::realtime_ns()). Basenode::getattr/setattrandfsetattrreplace duplicated device-nodegetattroverrides. Sharedfs::dir_nodecentralizes 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), supportsLOOKUP_NOFOLLOW, andopenwithO_CREATcan create through dangling symlink chains.rename,symlink,O_TRUNC(writable regular files only), andO_EXCLare wired through VFS and Linuxrename/renameat/symlink/symlinkatsyscalls; 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()andrealtime_ns()are inlined offrtc::boot_unix_ns(). Syscall path scratch buffers move fromkzalloctouzallocwhere appropriate.Reviewed by Cursor Bugbot for commit 6dbcf7a. Bugbot is set up for automated code reviews on this repo. Configure here.