Skip to content

Conversation

@appcypher
Copy link
Member

Summary

This PR implements platform-specific symlink handling during tar extraction to support stat virtualization on symlinks, matching the recent file-backed symlink implementation in libkrun.

Changes

  • Linux: Creates file-backed symlinks instead of regular symlinks

    • Symlink targets are stored as file content (regular files with mode 0600)
    • The original file type (S_IFLNK) and permissions are preserved in the user.containers.override_stat xattr
    • This works around Linux filesystem limitations where xattrs cannot be set on symlinks
  • macOS: Continues using regular symlinks with enhanced xattr support

    • Uses the XATTR_NOFOLLOW flag to set xattrs directly on symlinks
    • Preserves the original uid:gid:mode in the override stat xattr

Context

This change is required to support the new file-backed symlink representation in libkrun's filesystem implementations (overlayfs and passthrough). Without this, we cannot properly virtualize uid/gid/mode for symlinks in container filesystems on Linux.

Testing

  • Builds successfully on Linux
  • Existing tests pass
  • Manual testing with tar files containing symlinks
  • Verified xattr content on both platforms

Related

  • Depends on libkrun commit 9d77a4c (feat(fs): implement file-backed symlinks with virtualized stats for Linux)

Add platform-specific symlink handling during tar extraction to support
stat virtualization for symlinks:

- Linux: Create file-backed symlinks (regular files with symlink target as content)
  to work around xattr limitations on symlinks. The S_IFLNK file type is preserved
  in the override_stat xattr.

- macOS: Extract symlinks normally and set xattrs using XATTR_NOFOLLOW flag
  to store override stats directly on symlinks.

This enables proper uid:gid:mode virtualization for symlinks in container
filesystems, matching the implementation in libkrun's filesystem layer.
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