[CentOS] [semi-OT] C7 Possible bug but I can't determine what tool has the problem

Thu Jan 16 07:40:20 UTC 2020
Alessandro Baggi <alessandro.baggi at gmail.com>

Il 16/01/20 02:21, Gordon Messmer ha scritto:
> On 1/15/20 8:18 AM, Alessandro Baggi wrote:
>> Then I sync src/ to dest/ using "rsync -avS  src/ dest/", all ok but 
>> when I run "du -h dest/testfile" I get 0 and if I run "du -b 
>> dest/testfile" I get the correct size in bytes. 
> That's not a bug, that's what sparse files are.
> In POSIX systems, it's possible to treat a regular file like memory, 
> and one of the things you might do with such a feature is use a file 
> to keep track of the last time a user logged in.  The simplest way to 
> so that is to save the time value at the offset of the user's UID.  My 
> uid is 556600005, so if the file weren't sparse, that one entry would 
> create an enormous file, but with sparse files, the system only needs 
> to allocate one block to store that value.  If a process reads that 
> file, it will get all zeros from the OS until it reaches the date 
> stored at my uid offset.
> Applications can't tell whether a given set of zeros in a file are 
> actual zeros on disk, or if they're simply parts of the file that 
> haven't been written to, so when you tell rsync to create sparse 
> files, it will do its best to identify blocks that are all zeros and 
> simply not write to those on the destination.  Thus, if you use 
> /dev/zero to create a file on the source and then rsync it with -S, 
> the destination file will use zero blocks of storage. Naturally, that 
> can only be true with files whose contents are null bytes, as you get 
> from /dev/zero.
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos

Thank you for your answer. I appreciated it.