aboutsummaryrefslogtreecommitdiff
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2003-02-20 11:12:44 +0000
committerCorinna Vinschen <corinna@vinschen.de>2003-02-20 11:12:44 +0000
commit3a88cf1b10619c7be2d1b4539f76f761db4a1202 (patch)
treeca2f45cdcf5b8029c53f01dd012a00a182817fe8 /winsup
parent7920792369b18fd7d796a61aa7f3dda98c1957c8 (diff)
downloadnewlib-3a88cf1b10619c7be2d1b4539f76f761db4a1202.zip
newlib-3a88cf1b10619c7be2d1b4539f76f761db4a1202.tar.gz
newlib-3a88cf1b10619c7be2d1b4539f76f761db4a1202.tar.bz2
* autoload.cc (GetCompressedFileSize): Add.
* fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Compute st_blocks value from GetCompressedFileSize() if available.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog6
-rw-r--r--winsup/cygwin/autoload.cc1
-rw-r--r--winsup/cygwin/fhandler_disk_file.cc15
3 files changed, 21 insertions, 1 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 7d2ddcc..2765939 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,9 @@
+2003-02-20 Corinna Vinschen <corinna@vinschen.de>
+
+ * autoload.cc (GetCompressedFileSize): Add.
+ * fhandler_disk_file.cc (fhandler_disk_file::fstat_helper): Compute
+ st_blocks value from GetCompressedFileSize() if available.
+
2003-02-18 Vaclav Haisman <V.Haisman@sh.cvut.cz>
* wincap.h (wincaps::supports_sparse_files): New flag.
diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc
index 805055c..d071ab1 100644
--- a/winsup/cygwin/autoload.cc
+++ b/winsup/cygwin/autoload.cc
@@ -497,6 +497,7 @@ LoadDLLfunc (CoCreateInstance, 20, ole32)
LoadDLLfuncEx (CancelIo, 4, kernel32, 1)
LoadDLLfuncEx (CreateHardLinkA, 12, kernel32, 1)
LoadDLLfuncEx (CreateToolhelp32Snapshot, 8, kernel32, 1)
+LoadDLLfuncEx2 (GetCompressedFileSizeA, 8, kernel32, 1, 0xffffffff)
LoadDLLfuncEx (GetConsoleWindow, 0, kernel32, 1)
LoadDLLfuncEx2 (IsDebuggerPresent, 0, kernel32, 1, 1)
LoadDLLfuncEx (Process32First, 8, kernel32, 1)
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc
index 27e6217..f0971e9 100644
--- a/winsup/cygwin/fhandler_disk_file.cc
+++ b/winsup/cygwin/fhandler_disk_file.cc
@@ -260,7 +260,20 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc,
}
buf->st_blksize = S_BLKSIZE;
- buf->st_blocks = (buf->st_size + S_BLKSIZE - 1) / S_BLKSIZE;
+
+ /* GetCompressedFileSize() gets autoloaded. It returns INVALID_FILE_SIZE
+ if it doesn't exist. Since that's also a valid return value on 64bit
+ capable file systems, we must additionally check for the win32 error. */
+ nFileSizeLow = GetCompressedFileSizeA (pc->get_win32 (), &nFileSizeHigh);
+ if (nFileSizeLow != INVALID_FILE_SIZE || GetLastError () == NO_ERROR)
+ /* On systems supporting compressed (and sparsed) files,
+ GetCompressedFileSize() returns the actual amount of
+ bytes allocated on disk. */
+ buf->st_blocks = (((__off64_t)nFileSizeHigh << 32)
+ + nFileSizeLow + S_BLKSIZE - 1) / S_BLKSIZE;
+ else
+ /* Just compute no. of blocks from file size. */
+ buf->st_blocks = (buf->st_size + S_BLKSIZE - 1) / S_BLKSIZE;
buf->st_mode = 0;
/* Using a side effect: get_file_attibutes checks for