-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Fix UF_HIDDEN causing st_flags to be dropped in ConvertFileStatus; add PAL_UF_HIDDEN static assert #125710
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Copilot
wants to merge
7
commits into
main
Choose a base branch
from
copilot/fix-uf-hidden-st-flags-issue
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+56
−2
Open
Fix UF_HIDDEN causing st_flags to be dropped in ConvertFileStatus; add PAL_UF_HIDDEN static assert #125710
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
8e92aa5
Initial plan
Copilot 08b95f6
Fix UF_HIDDEN dropping st_flags in ConvertFileStatus; add static asse…
Copilot 1a6d59a
Address PR review feedback: fix comment grammar and gate UserFlags on…
Copilot 682f85f
Add test verifying toggling Hidden preserves other BSD user flags
danmoseley 9405d54
Move test to Unix-only file to fix cross-platform compilation
danmoseley 7375609
Improve static assert comment per reviewer feedback
danmoseley de316f0
Merge branch 'main' into copilot/fix-uf-hidden-st-flags-issue
danmoseley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
...braries/System.Runtime/tests/System.IO.FileSystem.Tests/FileInfo/GetSetAttributes.Unix.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using Xunit; | ||
|
|
||
| namespace System.IO.Tests | ||
| { | ||
| public partial class FileInfo_GetSetAttributes | ||
| { | ||
| [Fact] | ||
| [PlatformSpecific(TestPlatforms.OSX)] | ||
| public void TogglingHiddenAttribute_PreservesOtherUserFlags() | ||
| { | ||
| // UF_NODUMP (0x01) is a harmless BSD user flag that any file owner can set/clear. | ||
| const uint UF_NODUMP = 0x01; | ||
| const uint UF_HIDDEN = (uint)Interop.Sys.UserFlags.UF_HIDDEN; | ||
|
|
||
| string path = GetTestFilePath(); | ||
| File.Create(path).Dispose(); | ||
|
|
||
| // Set UF_NODUMP on the file directly via lchflags. | ||
| Assert.Equal(0, Interop.Sys.LChflags(path, UF_NODUMP)); | ||
| Assert.Equal(0, Interop.Sys.Stat(path, out Interop.Sys.FileStatus before)); | ||
| Assert.NotEqual(0u, before.UserFlags & UF_NODUMP); | ||
|
|
||
| // Toggle Hidden ON via the public API — this must preserve UF_NODUMP. | ||
| var fi = new FileInfo(path); | ||
| fi.Attributes |= FileAttributes.Hidden; | ||
|
|
||
| Assert.Equal(0, Interop.Sys.Stat(path, out Interop.Sys.FileStatus afterSet)); | ||
| Assert.NotEqual(0u, afterSet.UserFlags & UF_HIDDEN); | ||
| Assert.NotEqual(0u, afterSet.UserFlags & UF_NODUMP); | ||
|
|
||
| // Toggle Hidden OFF — UF_NODUMP must still survive. | ||
| fi.Refresh(); | ||
| fi.Attributes &= ~FileAttributes.Hidden; | ||
|
|
||
| Assert.Equal(0, Interop.Sys.Stat(path, out Interop.Sys.FileStatus afterClear)); | ||
| Assert.Equal(0u, afterClear.UserFlags & UF_HIDDEN); | ||
| Assert.NotEqual(0u, afterClear.UserFlags & UF_NODUMP); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.