From ec3b136a64f8adaa39f454acefb106952a6139f5 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 16 Jun 2005 15:46:40 +0000 Subject: [PATCH] * syscalls.cc (statvfs): Handle the case when GetDiskFreeSpaceEx succeeds but GetDiskFreeSpace fails by faking bytes-per-sector and sectors-per-cluster values. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/syscalls.cc | 19 +++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3a465ee50..7011bff6f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2005-06-16 Corinna Vinschen + + * 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 * cygthread.cc (cygthread::detach): Fix debugging output. diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index fa92b1b46..e5bd72c13 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -1731,16 +1731,27 @@ statvfs (const char *fname, struct statvfs *sfs) ULARGE_INTEGER availb, freeb, totalb; DWORD spc, bps, availc, freec, totalc, vsn, maxlen, flags; - BOOL status; + BOOL status, statusex; push_thread_privilege (SE_CHANGE_NOTIFY_PRIV, true); /* GetDiskFreeSpaceEx must be called before GetDiskFreeSpace on WinME, to avoid the MS KB 314417 bug */ - status = GetDiskFreeSpaceEx (root, &availb, &totalb, &freeb); - if (GetDiskFreeSpace (root, &spc, &bps, &freec, &totalc)) + statusex = GetDiskFreeSpaceEx (root, &availb, &totalb, &freeb); + 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); totalc = totalb.QuadPart / (spc*bps); -- 2.43.5