Skip to content

Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android)#126316

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-permission-denied-android
Draft

Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android)#126316
Copilot wants to merge 2 commits intomainfrom
copilot/fix-permission-denied-android

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 30, 2026

Android's SELinux app sandbox denies link syscalls from untrusted apps, causing UnauthorizedAccessException in any test that calls File.CreateHardLink. This produced 154 CI failures across all Android architectures (x86/arm/arm64/x64) on both Mono and CoreCLR.

Description

All test methods in System.Formats.Tar.Tests that call File.CreateHardLink — either directly or via the shared CreateSourceDirectoryForCreateFromDirectory_UsesWriterOptions() helper — are now gated with [ConditionalFact/ConditionalTheory(typeof(MountHelper), nameof(MountHelper.CanCreateHardLinks))]. This is the same pattern already used in the same files for symbolic-link tests.

Changed tests:

  • TarWriter_WriteEntry_File_Tests.WriteEntry_HardLinks
  • TarFile_ExtractToDirectory_File_Tests.HardLinkExtractionRoundtrip
  • TarFile_ExtractToDirectory_File_Tests.HardLinkExtraction_CopyContents
  • TarFile_ExtractToDirectoryAsync_File_Tests.HardLinkExtraction_CopyContentsAsync
  • TarFile_CreateFromDirectory_{File,Stream}_Tests.CreateFromDirectory_UsesWriterOptions
  • TarFile_CreateFromDirectoryAsync_{File,Stream}_Tests.CreateFromDirectoryAsync_UsesWriterOptions

Note: the guard is required even for TarHardLinkMode.CopyContents / preserveLinks=false variants — those tests still invoke File.CreateHardLink during setup to create the source fixture.

MountHelper.CanCreateHardLinks does a live capability probe (Lazy<bool>), so tests are skipped correctly on any platform that disallows hard links, not just Android.

…ks guards

Android's SELinux app sandbox prohibits hard link creation (denied { link }).
Tests that call File.CreateHardLink fail with UnauthorizedAccessException.
Guard all affected tests with [ConditionalFact/ConditionalTheory(typeof(MountHelper),
nameof(MountHelper.CanCreateHardLinks))] to skip them when hard links are unavailable.

Agent-Logs-Url: https://github.com/dotnet/runtime/sessions/9ff99a47-c680-4c34-9df0-eb63eaf86bdd

Co-authored-by: rzikm <32671551+rzikm@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix UnauthorizedAccessException for creating hard links in Android app Skip System.Formats.Tar hard-link tests on platforms that can't create hard links (Android) Mar 30, 2026
Copilot AI requested a review from rzikm March 30, 2026 14:11
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-formats-tar
See info in area-owners.md if you want to be subscribed.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UnauthorizedAccessException: Permission denied creating hard links in Android app sandbox

2 participants