Skip to content

Fix symlink storage and add directory reparenting - #12

Open
flowerishere wants to merge 2 commits into
arihant2math:mainfrom
flowerishere:main
Open

flowerishere wants to merge 2 commits into
arihant2math:mainfrom
flowerishere:main

Conversation

@flowerishere

Copy link
Copy Markdown

This is a follow-up to MOSS #322 (https://github.com/hexagonal-sun/moss-kernel/pull/322). That PR needed a couple of workarounds for symlinks and moving directories, so I’m bringing the relevant fixes into ext4plus.

For symlinks, the main fix is to stop treating inline target bytes as block pointers on the last unlink. This also fixes the 60-byte boundary: targets up to 59 bytes stay inline, while longer targets use a data block.

The other part adds Dir::reparent(old_parent, new_parent). It updates the existing .. entry and its checksum without rebuilding the directory or its htree index. Moving the directory entries, updating parent link counts, and preventing cycles are still the caller’s responsibility.

I also added checks around symlink creation and some error handling for failed writes, along with regression tests. Both commits passed all eight feature combinations, and the modified test images passed e2fsck.

Use inode block accounting to distinguish fast symlinks from block-backed
targets and skip block-map traversal when freeing inline targets. Store
60-byte targets in a data block and reject empty or oversized targets
before allocating an inode.

Validate the parent and check for existing names before creation. Reclaim
unpublished inodes on initialization or target-write failures, while
retaining entries already published when directory insertion reports an
I/O error.

Add ext2/ext4 boundary, hard-link, invalid-request, and injected-write
failure coverage. Validate all eight std/sync/multi-threaded feature
combinations with filesystem checks enabled.
Expose Dir::reparent(old_parent, new_parent) as a raw directory rename
building block. Validate the dot records, htree layout, and destination
inode before changing only the .. inode number and first-block checksum.
Leave namespace moves, cycle prevention, and parent link counts to callers.

Reject corrupt htree counts before checksum slicing and attempt to restore
the original disk block when the update reports a write failure.

Cover linear directories, htree roots at two depths, invalid layouts and
requests, no-op calls, and errors before or after partial/full writes.
Copilot AI balanced review requested due to automatic review settings October 14, 2026 08:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

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.

2 participants