Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 954aabd

Browse files
author
Jonathan Miller
committed
Fixing last failing tests on Linux
1 parent 2589d83 commit 954aabd

File tree

4 files changed

+11
-20
lines changed

4 files changed

+11
-20
lines changed

src/Common/src/Interop/Linux/libc/Interop.statfs.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ internal static partial class libc
1111
/// <summary>
1212
/// Internal FileSystem names and magic numbers taken from man(2) statfs
1313
/// </summary>
14+
/// <remarks>
15+
/// These value names MUST be kept in sync with those in DriveInfo.Unix.GetDriveType
16+
/// </remarks>
1417
internal enum LinuxFileSystemTypes : long
1518
{
1619
adfs = 0xadf5,
@@ -69,23 +72,23 @@ internal unsafe struct fsid_t
6972
[StructLayout(LayoutKind.Sequential)]
7073
internal unsafe struct statfs
7174
{
72-
internal int f_type;
73-
internal int f_bsize;
75+
internal long f_type;
76+
internal long f_bsize;
7477
internal ulong f_blocks;
7578
internal ulong f_bfree;
7679
internal ulong f_bavail;
7780
internal ulong f_files;
7881
internal ulong f_ffree;
7982
internal fsid_t f_fsid;
80-
internal int f_namelen;
81-
internal int f_frsize;
82-
internal int f_flags;
83-
internal fixed int f_space[4];
83+
internal long f_namelen;
84+
internal long f_frsize;
85+
internal long f_flags;
86+
internal fixed long f_space[4];
8487
}
8588

8689
internal static unsafe String GetMountPointFsType(statfs data)
8790
{
88-
return data.f_type.ToString();
91+
return ((LinuxFileSystemTypes)data.f_type).ToString();
8992
}
9093
}
9194
}

src/Common/src/Interop/Unix/libc/Interop.mountpoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ internal static unsafe statfs GetStatFsForDriveName(string name)
5353
}
5454
else
5555
{
56+
printf(System.Runtime.InteropServices.Marshal.SizeOf<statfs>().ToString() + "\r\n");
5657
printf("Should be here\r\n");
5758
return data;
5859
}

src/System.IO.FileSystem.DriveInfo/src/System/IO/DriveInfo.Unix.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ namespace System.IO
88
{
99
public sealed partial class DriveInfo
1010
{
11-
[DllImport("libc")]
12-
static extern int printf(string data);
13-
1411
private static string NormalizeDriveName(string driveName)
1512
{
1613
if (driveName.Contains("\0"))
@@ -30,7 +27,6 @@ public DriveType DriveType
3027
get
3128
{
3229
Interop.libc.statfs data = Interop.libc.GetStatFsForDriveName(Name);
33-
printf("Got data for name" + Name + "\r\n");
3430
return GetDriveType(Interop.libc.GetMountPointFsType(data));
3531
}
3632
}
@@ -98,7 +94,6 @@ public String VolumeLabel
9894
/// <returns>The recognized drive type.</returns>
9995
private static DriveType GetDriveType(string fileSystemName)
10096
{
101-
printf("Got type of " + fileSystemName + "\r\n");
10297
// This list is based primarily on "man fs", "man mount", "mntent.h", "/proc/filesystems",
10398
// and "wiki.debian.org/FileSystem". It can be extended over time as we
10499
// find additional file systems that should be recognized as a particular drive type.

src/System.IO.FileSystem.DriveInfo/tests/DriveInfo.Unix.Tests.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ namespace System.IO.FileSystem.DriveInfoTests
88
{
99
public partial class DriveInfoUnixTests
1010
{
11-
[Runtime.InteropServices.DllImport("libc")]
12-
private static extern int printf(string data);
13-
1411
[Fact]
1512
[PlatformSpecific(PlatformID.AnyUnix)]
1613
public void TestConstructor()
@@ -54,15 +51,10 @@ public void TestProperties()
5451
Assert.Equal("/", root.Name);
5552
Assert.Equal("/", root.RootDirectory.FullName);
5653
Assert.Equal(DriveType.Fixed, root.DriveType);
57-
printf("Checked type\r\n");
5854
Assert.True(root.IsReady);
59-
printf("Checked if ready\r\n");
6055
Assert.True(root.AvailableFreeSpace > 0);
61-
printf("Checked free space\r\n");
6256
Assert.True(root.TotalFreeSpace > 0);
63-
printf("checked total space\r\n");
6457
Assert.True(root.TotalSize > 0);
65-
printf("done\r\n");
6658
}
6759
}
6860
}

0 commit comments

Comments
 (0)