Skip to content

DriveInfo.DriveType returns Unknown for exfat filesystems #115962

@namtabmai

Description

@namtabmai

Description

When using DriveInfo to check the DriveType of an exfat filesystem, it returns unknown. Also the filesystem shows as blank.

Reproduction Steps

Create a file based filesystem for a quick test (likely need to sudo to mount the test.img)

dd if=/dev/zero of=test.img bs=1M count=1024
mkfs.exfat test.img
mount -o loop test.img /mnt/testing
DriveInfo d = new DriveInfo("/mnt/test");
Console.WriteLine("Drive {0}", d.Name);
Console.WriteLine("  Drive type: {0}", d.DriveType);
Console.WriteLine("  File system: {0}", d.DriveFormat);

Expected behavior

I think, something like this. Similar to exfat

Drive /mnt/test
  Drive type: Fixed
  File system: msdos

Actual behavior

Drive /mnt/test
  Drive type: Unknown
  File system: 

Regression?

No, seems to have been this way since exfat was added as a filesystem type

Known Workarounds

None

Configuration

.Net 9.0.105
Linux - Arch
x86_64
Might be specific to Linux, unable to try on Windows or Mac

Other information

The problem appears to be because of a missing entry in the UnixFileSystemTypes enum

https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs

The FormatInfo uses this to look up the format/type, defaulting to Unknown / string.Empty when the entry is missing.

https://github.com/dotnet/runtime/blob/main/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MountPoints.FormatInfo.cs#L61

The comments in UnixFileSystemTypes say it should kept inline with the statfs man page, only the stat coreutils added the exfat with it's corresponding magic number without updating the man page.

https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v8.32-109-ga5e0d8f387

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-System.IOhelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions