LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Why does 'stat -c%s\ %b small_dir_size' report a 0 block size? (https://www.linuxquestions.org/questions/linux-newbie-8/why-does-stat-cs%5C-b-small_dir_size-report-a-0-block-size-4175677039/)

doru 06-13-2020 11:53 PM

Why does 'stat -c%s\ %b small_dir_size' report a 0 block size?
 
Code:

~/tmp]$ mkdir test1
~/tmp]$ echo abcd >> test1/test.txt
~/tmp]$ stat -c"size in bytes: %s, size in blocks: %b, size of a block: %B" test1
size in bytes: 21, size in blocks: 0, size of a block: 512
~/tmp]$

xfs file system, 4kB minimum allocation unit on disk

berndbausch 06-14-2020 01:00 AM

I guess that the file is so small that it is entirely contained in the inode (reference), not occupying any data blocks.

MadeInGermany 06-14-2020 07:43 AM

I think that only du can report the allocated blocks properly.

doru 06-20-2020 03:03 AM

Quote:

Originally Posted by MadeInGermany (Post 6134190)
I think that only du can report the allocated blocks properly.

stat, ls -l and du are fully coherent on this.

shruggy 06-20-2020 03:02 PM

The same reference as given by berndbausch, but more relevant part: Shortform Directories.


All times are GMT -5. The time now is 03:07 AM.