Skip to content

tests/virtiofs-misc: add rename-overwrite fchmod subtest#705

Open
slp wants to merge 1 commit into
containers:mainfrom
slp:virtiofs-rename-overwrite-tests
Open

tests/virtiofs-misc: add rename-overwrite fchmod subtest#705
slp wants to merge 1 commit into
containers:mainfrom
slp:virtiofs-rename-overwrite-tests

Conversation

@slp
Copy link
Copy Markdown
Collaborator

@slp slp commented Jun 3, 2026

Add regression test for PR #700, which fixed a file descriptor leak on macOS when renaming over an existing file with open fds.

The bug: macOS virtio-fs uses volfs paths (/.vol/{dev}/{ino}) which become invalid when the inode's last link is removed. When rename() replaces a file, the old target loses its directory entry, breaking subsequent operations on still-open file descriptors.

This broke apt/dpkg atomic writes with errors like: "Problem closing the file /var/lib/dpkg/status - close (2: No such file or directory)"

The fix stores an fd to the doomed target before rename, preserving access to the unlinked inode for tracked fds.

The test verifies that fchmod() works on an open fd after the file has been atomically replaced via rename.

Assisted-by: Claude Code:claude-opus-4.6

Add regression test for PR containers#700, which fixed a file descriptor leak
on macOS when renaming over an existing file with open fds.

The bug: macOS virtio-fs uses volfs paths (/.vol/{dev}/{ino}) which
become invalid when the inode's last link is removed. When rename()
replaces a file, the old target loses its directory entry, breaking
subsequent operations on still-open file descriptors.

This broke apt/dpkg atomic writes with errors like:
"Problem closing the file /var/lib/dpkg/status - close (2: No such file or directory)"

The fix stores an fd to the doomed target before rename, preserving
access to the unlinked inode for tracked fds.

The test verifies that fchmod() works on an open fd after the file
has been atomically replaced via rename.

Assisted-by: Claude Code:claude-opus-4.6
Signed-off-by: Sergio Lopez <slp@redhat.com>
@slp slp force-pushed the virtiofs-rename-overwrite-tests branch from 9264d08 to 85efa04 Compare June 3, 2026 15:33
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