4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-02-28 03:27:46 +08:00

* syscalls.cc (statvfs): Handle the case when GetDiskFreeSpaceEx

succeeds but GetDiskFreeSpace fails by faking bytes-per-sector and
	sectors-per-cluster values.
This commit is contained in:
Corinna Vinschen 2005-06-16 15:46:40 +00:00
parent 842db59275
commit ec3b136a64
2 changed files with 21 additions and 4 deletions

View File

@ -1,3 +1,9 @@
2005-06-16 Corinna Vinschen <corinna@vinschen.de>
* syscalls.cc (statvfs): Handle the case when GetDiskFreeSpaceEx
succeeds but GetDiskFreeSpace fails by faking bytes-per-sector and
sectors-per-cluster values.
2005-06-15 Christopher Faylor <cgf@timesys.com> 2005-06-15 Christopher Faylor <cgf@timesys.com>
* cygthread.cc (cygthread::detach): Fix debugging output. * cygthread.cc (cygthread::detach): Fix debugging output.

View File

@ -1731,16 +1731,27 @@ statvfs (const char *fname, struct statvfs *sfs)
ULARGE_INTEGER availb, freeb, totalb; ULARGE_INTEGER availb, freeb, totalb;
DWORD spc, bps, availc, freec, totalc, vsn, maxlen, flags; DWORD spc, bps, availc, freec, totalc, vsn, maxlen, flags;
BOOL status; BOOL status, statusex;
push_thread_privilege (SE_CHANGE_NOTIFY_PRIV, true); push_thread_privilege (SE_CHANGE_NOTIFY_PRIV, true);
/* GetDiskFreeSpaceEx must be called before GetDiskFreeSpace on /* GetDiskFreeSpaceEx must be called before GetDiskFreeSpace on
WinME, to avoid the MS KB 314417 bug */ WinME, to avoid the MS KB 314417 bug */
status = GetDiskFreeSpaceEx (root, &availb, &totalb, &freeb); statusex = GetDiskFreeSpaceEx (root, &availb, &totalb, &freeb);
if (GetDiskFreeSpace (root, &spc, &bps, &freec, &totalc)) status = GetDiskFreeSpace (root, &spc, &bps, &freec, &totalc);
if (!status && statusex)
{ {
if (status) /* Grrr, this can happen on 9x when a share isn't attached to
a drive letter. Fake, fake, hoorah. */
status = TRUE;
bps = 512;
spc = 8;
while ((totalb.QuadPart % (spc*bps)) && spc > 1)
spc >>= 1;
}
if (status)
{
if (statusex)
{ {
availc = availb.QuadPart / (spc*bps); availc = availb.QuadPart / (spc*bps);
totalc = totalb.QuadPart / (spc*bps); totalc = totalb.QuadPart / (spc*bps);