This is the mail archive of the cygwin-patches mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix stat.st_blocks for files compressed with CompactOS method


Cygwin 2.8.0 returns stat.st_blocks = 0 if a file is compressed with CompactOS method (at least on Win10 1607):

Testcase:

$ ls -ls file
280 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

$ compact /c file
...
$ ls -ls file
56 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

$ compact /u file
...
$ compact /c /exe file
...
$ ls -ls file
0 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

This is because StandardInformation.AllocationSize is always 0 for theses files. CompressedFileSize returns the correct value.

This is likely related to the interesting method how these files are encoded in the MFT: The default $DATA stream is a sparse stream with original size but no allocated blocks.
An alternate $DATA stream WofCompressedData contains the compressed data.
An additional $REPARSE_POINT possibly marks this file a special and lets accesses fail on older Windows releases (and on Linux, most current forensic tools, ...).

With the attached patch, stat.st_blocks work as expected:

$ ls -ls file
48 -rw-r--r-- 1 ... ... 285363 Apr 22 13:52 file

The only drawback is an unnecessary FileCompressionInformation query for sparse files with no blocks.

Christian

Attachment: cygwin-2.8-fix-st_blocks-for-compact-os.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]