[Mono-dev] [PATCH] DriveInfo implementation - volume space

Javier Martín lordhabbit at gmail.com
Fri Dec 7 07:26:08 EST 2007


Well, everything with a start has its end, and it's time for this
particular one. This patch implements the volume space properties in
[corlib]System.IO.DriveInfo, both in Windows and Linux. Incidentally,
it also implements the helper WindowsGetDrives method, which was
previously a stub, but only to the point that's useful to this patch:
it still lacks the functionality to detect the volume filesystem type.

This functionality has been implemented through a new internal call in
icall.c & icall-def.h (DRVINF_1) that relies on a Win32 API not
previously replicated in io-layer (GetDiskFreeSpaceEx). Thus, some
files in io-layer have been modified:
    * volumes.[hc] (NEW) : volume & fs management. Contains the new
win32 call POSIX replacement, based on statvfs.
    * types.h : corrected the WapiLargeInteger and added its unsigned
version, required by the new call.
    * uglify.h : added the typedefs for WapiULargeInteger
    * wapi.h & Makefile.am : reflect the new files inclusion

The build and test environment was:
    * Linux: Ubuntu 7.10 (kernel 2.6.22), GCC 4.1, sh = dash
    * Windows: XP Pro x64 (5.2) + cygwin/32, GCC 3.4, sh = bash, make replaced

I also include a test case (Program.cs) for the new functionality.
When compiled and run with the drive/mount to get info about (i.e.
Program.exe C:), it should output something like:
    NTFS
    30056591360     30056591360     209711706112
    30056591360     30056591360     209711706112
    30056591360     30056591360     209711706112
    30056595456     30056595456     209711706112
    30056595456     30056595456     209711706112
    21619003392     21619003392     209711706112
    21619003392     21619003392     209711706112
    21619003392     21619003392     209711706112
    30056595456     30056595456     209711706112
Where the figures represent available free space, total free space and
total FS size in bytes. The filesystem type will appear in MS.NET and
Mono Linux, but not in Mono Windows (incomplete implementation of
WindowsGetDrives). The program will run indefinitely unless killed,
outputting data each second, so you can see how it altered when I
started a file copy and then restored when I cancelled it.

As always, I hope this doesn't break anything ^^

Habbit

OT: it seems that on file copies, Windows immediately decrements free
space by the full file size, while Linux does so gradually.
OT2: why does it take waaaaay longer to compile mono in cygwin than in
Linux? Is it bash, cygwin.dll or both?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mono.patch
Type: application/octet-stream
Size: 6452 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071207/37d5a968/attachment.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mcs.patch
Type: application/octet-stream
Size: 4326 bytes
Desc: not available
Url : http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071207/37d5a968/attachment-0001.obj 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Program.cs
Url: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20071207/37d5a968/attachment.pl 


More information about the Mono-devel-list mailing list