Skip to content

Commit f842935

Browse files
committed
Remove symlink specific code from this PR
Removes the symlink specific code as per dotnet#49555 (comment). This will be reverted (and modified) as per dotnet#49555 (comment) into dotnet#52639.
1 parent 17868b1 commit f842935

8 files changed

Lines changed: 2 additions & 75 deletions

File tree

src/libraries/Common/src/Interop/OSX/Interop.libc.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,5 @@ internal struct AttrList
2525

2626
[DllImport(Libraries.libc, EntryPoint = "setattrlist", SetLastError = true)]
2727
internal static unsafe extern int setattrlist(string path, AttrList* attrList, void* attrBuf, nint attrBufSize, CULong options);
28-
29-
internal const uint FSOPT_NOFOLLOW = 0x00000001;
3028
}
3129
}

src/libraries/Native/Unix/System.Native/pal_time.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int32_t SystemNative_UTimensat(const char* path, TimeSpec* times)
3333

3434
updatedTimes[1].tv_sec = (time_t)times[1].tv_sec;
3535
updatedTimes[1].tv_nsec = (long)times[1].tv_nsec;
36-
while (CheckInterrupted(result = utimensat(AT_FDCWD, path, updatedTimes, AT_SYMLINK_NOFOLLOW)));
36+
while (CheckInterrupted(result = utimensat(AT_FDCWD, path, updatedTimes, 0)));
3737
#else
3838
struct timeval updatedTimes[2];
3939
updatedTimes[0].tv_sec = (long)times[0].tv_sec;

src/libraries/System.IO.FileSystem/tests/Base/BaseGetSetTimes.cs

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ public abstract class BaseGetSetTimes<T> : FileSystemTest
2323

2424
protected abstract T GetExistingItem();
2525
protected abstract T GetMissingItem();
26-
protected abstract T CreateSymlinkToItem(T item);
2726

2827
protected abstract string GetItemPath(T item);
2928

@@ -130,40 +129,6 @@ public void SettingUpdatesPropertiesAfterAnother()
130129
});
131130
}
132131

133-
[Fact]
134-
[PlatformSpecific(~(TestPlatforms.Browser | TestPlatforms.Windows))]
135-
public void SettingUpdatesPropertiesOnSymlink()
136-
{
137-
// Browser is excluded as there is only 1 effective time store.
138-
139-
// This test makes sure that the times are set on the symlink itself.
140-
// It is needed as on OSX for example, the default for most APIs is
141-
// to follow the symlink to completion and set the time on that entry
142-
// instead (eg. the setattrlist will do this without the flag set).
143-
T item = CreateSymlinkToItem(GetExistingItem());
144-
145-
Assert.All(TimeFunctions(requiresRoundtripping: true), (function) =>
146-
{
147-
// Checking that milliseconds are not dropped after setter on supported platforms.
148-
DateTime dt = new DateTime(2004, 12, 1, 12, 3, 3, LowTemporalResolution ? 0 : 321, function.Kind);
149-
function.Setter(item, dt);
150-
DateTime result = function.Getter(item);
151-
Assert.Equal(dt, result);
152-
Assert.Equal(dt.ToLocalTime(), result.ToLocalTime());
153-
154-
// File and Directory UTC APIs treat a DateTimeKind.Unspecified as UTC whereas
155-
// ToUniversalTime treats it as local.
156-
if (function.Kind == DateTimeKind.Unspecified)
157-
{
158-
Assert.Equal(dt, result.ToUniversalTime());
159-
}
160-
else
161-
{
162-
Assert.Equal(dt.ToUniversalTime(), result.ToUniversalTime());
163-
}
164-
});
165-
}
166-
167132
[Fact]
168133
public void CanGetAllTimesAfterCreation()
169134
{

src/libraries/System.IO.FileSystem/tests/Directory/GetSetTimes.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,5 @@ public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtrippi
5151
((path) => Directory.GetLastWriteTimeUtc(path)),
5252
DateTimeKind.Utc);
5353
}
54-
55-
protected override string CreateSymlinkToItem(string item)
56-
{
57-
var link = item + ".link";
58-
if (Directory.Exists(link)) Directory.Delete(link);
59-
if (!MountHelper.CreateSymbolicLink(link, item, true) || !Directory.Exists(link)) throw new Exception("Could not create symlink.");
60-
return link;
61-
}
6254
}
6355
}

src/libraries/System.IO.FileSystem/tests/DirectoryInfo/GetSetTimes.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,5 @@ public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtrippi
5757
((testDir) => testDir.LastWriteTimeUtc),
5858
DateTimeKind.Utc);
5959
}
60-
61-
protected override DirectoryInfo CreateSymlinkToItem(DirectoryInfo item)
62-
{
63-
var link = new DirectoryInfo(item.FullName + ".link");
64-
if (link.Exists) link.Delete();
65-
bool failed = !MountHelper.CreateSymbolicLink(link.FullName, item.FullName, true);
66-
link.Refresh();
67-
if (failed || !link.Exists) throw new Exception("Could not create symlink.");
68-
return link;
69-
}
7060
}
7161
}

src/libraries/System.IO.FileSystem/tests/File/GetSetTimes.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,14 +103,6 @@ public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtrippi
103103
DateTimeKind.Utc);
104104
}
105105

106-
protected override string CreateSymlinkToItem(string item)
107-
{
108-
var link = item + ".link";
109-
if (File.Exists(link)) File.Delete(link);
110-
if (!MountHelper.CreateSymbolicLink(link, item, false) || !File.Exists(link)) throw new Exception("Could not create symlink.");
111-
return link;
112-
}
113-
114106
[ConditionalFact(typeof(PlatformDetection), nameof(PlatformDetection.IsNotInAppContainer))] // Can't read root in appcontainer
115107
[PlatformSpecific(TestPlatforms.Windows)]
116108
public void PageFileHasTimes()

src/libraries/System.IO.FileSystem/tests/FileInfo/GetSetTimes.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,6 @@ public override IEnumerable<TimeFunction> TimeFunctions(bool requiresRoundtrippi
103103
DateTimeKind.Utc);
104104
}
105105

106-
protected override FileInfo CreateSymlinkToItem(FileInfo item)
107-
{
108-
var link = new FileInfo(item.FullName + ".link");
109-
if (link.Exists) link.Delete();
110-
bool failed = !MountHelper.CreateSymbolicLink(link.FullName, item.FullName, false);
111-
link.Refresh();
112-
if (failed || !link.Exists) throw new Exception("Could not create symlink.");
113-
return link;
114-
}
115-
116106
[ConditionalFact(nameof(HighTemporalResolution))]
117107
public void CopyToMillisecondPresent()
118108
{

src/libraries/System.Private.CoreLib/src/System/IO/FileStatus.OSX.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ internal unsafe void SetCreationTime(string path, DateTimeOffset time)
2626
// setattrlist()", so we fall back to the method used on other unix
2727
// platforms, otherwise we throw an error if we get one, or invalidate
2828
// the cache if successful because otherwise it has invalid information.
29-
Interop.Error result = (Interop.Error)Interop.libc.setattrlist(path, &attrList, &timeSpec, sizeof(Interop.Sys.TimeSpec), new CULong(Interop.libc.FSOPT_NOFOLLOW));
29+
Interop.Error result = (Interop.Error)Interop.libc.setattrlist(path, &attrList, &timeSpec, sizeof(Interop.Sys.TimeSpec), default(CULong));
3030
if (result == Interop.Error.ENOTSUP)
3131
{
3232
SetCreationTime_StandardUnixImpl(path, time);

0 commit comments

Comments
 (0)