Thursday, June 03, 2004

GetDiskFreeSpaceEx lies about remote mount points

Has anyone else noticed that UNC destinations that are hosted on mount points don't provide correct information about how much disk space is available? They seem to always return the information related to their 'head unit', the drive they are mounted on.

For example, run this perl program on for a drive, and the ora01 mount point. (Win32::AdminMisc::GetDriveSpace is just a thin wrapper around GetDiskFreeSpaceEx)


use Win32::AdminMisc;
foreach my $d ('J:\\','J:\\ora01\\',
'\\\\xxxx\\j$\\','\\\\xxxx\\j$\\ora01\\') {
my @info=&Win32::AdminMisc::GetDriveSpace($d);
print "$d\n Total: $info[0]\n Free: $info[1]\n";
}


Output:

J:
Total: 9047773184
Free: 6996824064
J:\ora01
Total: 9047769088
Free: 77381632
\\xxxx\j$
Total: 9047773184
Free: 6996824064
\\xxxx\j$\ora01
Total: 9047773184
Free: 6996824064


Notice that the mount point returns the total and free information for J:\, instead of for itself.

This behavior is not limited to GetDiskFreeSpaceEx, dir reports the same incorrect information:


C:\temp>dir \\xxxx\j$\ora01\.
Directory of \\xxxx\j$\ora01

1 File(s) 0 bytes
1 Dir(s) 6,996,824,064 bytes free


And 6,996,... is the amount of free space on J:, not J:\ora01. The behavior is the same even if you have mapped a drive to the mount point.

Must be some flaw with the CIFS protocol, I suppose.

No comments: