[PATCH] Fix stat.st_blocks for files compressed with CompactOS method
Christian Franke
Christian.Franke@t-online.de
Sat Apr 22 14:34:00 GMT 2017
Corinna Vinschen wrote:
> Hi Christian,
>
> On Apr 22 14:50, Christian Franke wrote:
>> Cygwin 2.8.0 returns stat.st_blocks = 0 if a file is compressed with
>> CompactOS method (at least on Win10 1607):
>> [...]
>> 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:
>> [...]
>> - else if (::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
>> - | FILE_ATTRIBUTE_SPARSE_FILE)
>> + else if ((pfai->StandardInformation.AllocationSize.QuadPart == 0LL
>> + || ::has_attribute (attributes, FILE_ATTRIBUTE_COMPRESSED
>> + | FILE_ATTRIBUTE_SPARSE_FILE))
> Are you saying these files actually have no FILE_ATTRIBUTE_COMPRESSED
> bit set???
>
Yes. The only evidence is the CompressedSize.
There is also no visual emphasis in explorer listings.
Christian
More information about the Cygwin-patches
mailing list