Skip to content

fix: decrement nlink on unlink and preserve inode/nlink on rename#276

Open
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-unlink-nlink
Open

fix: decrement nlink on unlink and preserve inode/nlink on rename#276
Koan-Bot wants to merge 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/fix-unlink-nlink

Conversation

@Koan-Bot
Copy link
Contributor

@Koan-Bot Koan-Bot commented Mar 2, 2026

What

unlink() now decrements nlink on the unlinked file and on any remaining hard links sharing the same inode. rename() now preserves inode and nlink metadata.

Why

After link('/a', '/b') + unlink('/a'), both mocks retained stale nlink values — the remaining hard link /b still showed nlink=2 instead of nlink=1. Similarly, rename('/old', '/new') lost inode identity and link count, making the renamed file appear as a different inode.

How

  • unlink() method: scans %files_being_mocked for mocks sharing the same inode and decrements their nlink before decrementing self
  • __rename: copies inode and nlink alongside mode/uid/gid

Testing

  • t/symlink_link.t: unlink after link decrements nlink on remaining hard link; single-file unlink decrements nlink
  • t/rename.t: rename preserves inode and nlink values

🤖 Generated with Claude Code

@atoomic
Copy link
Contributor

atoomic commented Mar 3, 2026

@Koan-Bot rebase

@Koan-Bot
Copy link
Contributor Author

Koan-Bot commented Mar 3, 2026

Rebase: fix: decrement nlink on unlink and preserve inode/nlink on rename

Branch koan.atoomic/fix-unlink-nlink has been rebased onto master and force-pushed.

Actions

  • Read PR comments and review feedback
  • Rebased koan.atoomic/fix-unlink-nlink onto origin/master
  • Force-pushed koan.atoomic/fix-unlink-nlink to origin

Automated by Kōan

@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-unlink-nlink branch from 1dccd7c to 905ed39 Compare March 3, 2026 02:43
@atoomic atoomic marked this pull request as ready for review March 3, 2026 02:54
@Koan-Bot
Copy link
Contributor Author

Koan-Bot commented Mar 3, 2026

Rebase: fix: decrement nlink on unlink and preserve inode/nlink on rename

Branch koan.atoomic/fix-unlink-nlink has been rebased onto master and force-pushed.

Actions

  • Read PR comments and review feedback
  • Rebased koan.atoomic/fix-unlink-nlink onto origin/master
  • Force-pushed koan.atoomic/fix-unlink-nlink to origin

Automated by Kōan

@toddr
Copy link
Member

toddr commented Mar 19, 2026

@Koan-Bot rebase

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@Koan-Bot Koan-Bot force-pushed the koan.atoomic/fix-unlink-nlink branch from 905ed39 to 25674e8 Compare March 19, 2026 15:49
@Koan-Bot
Copy link
Contributor Author

Rebase: fix: decrement nlink on unlink and preserve inode/nlink on rename

Branch koan.atoomic/fix-unlink-nlink rebased onto master and force-pushed.

Diff: 3 files changed, 63 insertions(+), 1 deletion(-)

Review feedback was analyzed and applied.

Actions

  • Resolved merge conflicts (1 round(s))
  • Rebased koan.atoomic/fix-unlink-nlink onto upstream/master
  • Force-pushed koan.atoomic/fix-unlink-nlink to origin
  • CI passed

CI

CI passed.


Automated by Kōan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants