Bug 11923 - System.IO.DriveInfo.GetDrives() returns a single null drive
Summary: System.IO.DriveInfo.GetDrives() returns a single null drive
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: mscorlib (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-04-23 19:31 UTC by Andrew Barnes
Modified: 2014-07-17 08:00 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Test Case (1.08 KB, text/x-csharp)
2013-04-23 19:31 UTC, Andrew Barnes
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 11923 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description Andrew Barnes 2013-04-23 19:31:12 UTC
Created attachment 3860 [details]
Test Case

Running System.IO.DriveInfo.GetDrives() on my system returns a single drive, with Name.Length == 0 accessing most properties causes an exception:

Test case output:

$ mono ./DriveInfoTest.exe
Drive: 

Unhandled Exception:
System.ArgumentException: An empty file name is not valid.
  at System.IO.FileSystemInfo.CheckPath (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.DirectoryInfo..ctor (System.String path, Boolean simpleOriginalPath) [0x00000] in <filename unknown>:0 
  at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:.ctor (string)
  at System.IO.DriveInfo.get_RootDirectory () [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ArgumentException: An empty file name is not valid.
  at System.IO.FileSystemInfo.CheckPath (System.String path) [0x00000] in <filename unknown>:0 
  at System.IO.DirectoryInfo..ctor (System.String path, Boolean simpleOriginalPath) [0x00000] in <filename unknown>:0 
  at System.IO.DirectoryInfo..ctor (System.String path) [0x00000] in <filename unknown>:0 
  at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo:.ctor (string)
  at System.IO.DriveInfo.get_RootDirectory () [0x00000] in <filename unknown>:0 
  at Test.Main () [0x00000] in <filename unknown>:0 

Expected output:

$ mono ./DriveInfoTest.exe
Drive: /
Drive.RootDirectory: /
  File type: Unknown
  Volume label: /
  File system: 
  Available space to current user:   336752803840 bytes
  Total available space:             336752803840 bytes
  Total size of drive:               367505702912 bytes 
Drive: /run
Drive.RootDirectory: /run
  File type: Ram
  Volume label: /run
  File system: tmpfs
  Available space to current user:     8411750400 bytes
  Total available space:               8411750400 bytes
  Total size of drive:                 8413601792 bytes 

  ... Many more here ...

Drive.RootDirectory: /systems/virtuals/ovirt
  File type: Unknown
  Volume label: /systems/virtuals/ovirt
  File system: 
  Available space to current user:   336752803840 bytes
  Total available space:             336752803840 bytes
  Total size of drive:               348727934976 bytes 
Drive: /proc/sys/fs/binfmt_misc
Drive.RootDirectory: /proc/sys/fs/binfmt_misc
  File type: Unknown
  Volume label: /proc/sys/fs/binfmt_misc
  File system: 
  Available space to current user:              0 bytes
  Total available space:                        0 bytes
  Total size of drive:                          0 bytes 
Drive: /var/lib/nfs/rpc_pipefs
Drive.RootDirectory: /var/lib/nfs/rpc_pipefs
  File type: Unknown
  Volume label: /var/lib/nfs/rpc_pipefs
  File system: 
  Available space to current user:              0 bytes
  Total available space:                        0 bytes
  Total size of drive:                          0 bytes 
Drive: /proc/fs/nfsd
Drive.RootDirectory: /proc/fs/nfsd
  File type: Unknown
  Volume label: /proc/fs/nfsd
  File system: 
  Available space to current user:              0 bytes
  Total available space:                        0 bytes
  Total size of drive:                          0 bytes 
Total drives: 120

I performed some debugging and come up with the following patch which gives me the expected output:

Not sure if I am missing something here but the ignore_entry logic looks a little aggressive.

diff --git a/mono/io-layer/io.c b/mono/io-layer/io.c
index 579c48d..f354f72 100755
--- a/mono/io-layer/io.c
+++ b/mono/io-layer/io.c
@@ -3726,7 +3726,7 @@ add_drive_string (guint32 len, gunichar2 *buf, LinuxMountInfoParseState *state)
                else
                        ignore_entry = FALSE;
        } else
-               ignore_entry = TRUE;
+               ignore_entry = FALSE;
 
        if (!ignore_entry) {
                gunichar2 *dir;


Some details on my environment are:

$ uname -a
Linux b1 3.7.9+ #10 SMP Mon Mar 18 15:41:36 EST 2013 x86_64 AMD Phenom(tm) II X6 1100T Processor AuthenticAMD GNU/Linux
$ cat /proc/self/mountinfo | grep none       
15 18 0:3 / /proc rw,relatime - proc none rw
$ cat /proc/self/mountinfo| wc -l    
121
Comment 1 Andrew Barnes 2013-04-23 19:31:50 UTC
Mono version: 3.0.7