Skip to content

System.IO.DriveInfo returns invalid data for mounted optical drive volume in Linux if the volume label contains space #123347

Closed

Description

@13xforever

Description

When enumerating drive information using DriveInfo.GetDrives() the returned data may be invalid (incorrect Name, DriveType, and RootDirectory) for mounted optical disc if the volume label has spaces in it.
The exact same code worked in previous versions of .NET.

Reproduction Steps

var drives = System.IO.DriveInfo.GetDrives().ToList();
Console.WriteLine($"Found {drives.Count} drives);
foreach (var drive in drives)
{
    Console.WriteLine($"{drive.Name} (type: {drive.DriveType}): {drive.RootDirectory}");
}

run with dotnet run --framework 9.0 ./program.cs vs dotnet run ./program.cs with dotnet-sdk-10.0 installed

Expected behavior

Name and RootDirectory point to the mount point (usually something like /run/media/username/DISC LABEL), and DriveType == CDRom

Actual behavior

Name and RootDirectory are broken (/run/media/username/DISC\0403), and DriveType == NoRootDirectory

Regression?

Yes, the same code worked fine with .NET 8 and 9

Known Workarounds

No response

Configuration

Tested using .NET SDK 9.0.11 and 10.0.1 on Fedora 42, but I got reports from NixOS and Bazzite

Other information

No response

Activity

  1. added
    untriaged
    on Jan 19, 2026
  2. added
    needs-area-label
    on Jan 19, 2026
  3. added and removed
    needs-area-label
    on Jan 19, 2026
  4. dotnet-policy-service commented on Jan 19, 2026

    @dotnet-policy-service
    Contributor

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

  5. added and removed
    untriaged
    on Jul 15, 2026
  6. added this to the 12.0.0 milestone on Jul 15, 2026
  7. markusschaber commented on Oct 21, 2026

    @markusschaber

    We just got hit by that. The API Environment.GetLogicalDrives() is also affected by this issue, as it also calls Interop.Sys.GetAllMountPoints() under the hood. It seems there was a merge request with a proposed fix here which has been closed due to inactivity.
    The Problem also affects Debian, Ubuntu and other derivates (which is not surprising, as /proc/self/mountinfo basically is a Kernel API).

  8. krwq commented on Nov 9, 2026

    @krwq
    Member

    @13xforever @markusschaber I've opened PR with the fix, any chance you could try that out with your scenario (i.e. build repo, add test with your scenario and see if that works as expected)

  9. added a commit that references this issue on Nov 12, 2026
    e0bc8a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions