LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-13-2020, 11:53 PM   #1
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

Rep: Reputation: 19
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

Last edited by doru; 06-20-2020 at 03:01 AM.
 
Old 06-14-2020, 01:00 AM   #2
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
I guess that the file is so small that it is entirely contained in the inode (reference), not occupying any data blocks.
 
1 members found this post helpful.
Old 06-14-2020, 07:43 AM   #3
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,781

Rep: Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199Reputation: 1199
I think that only du can report the allocated blocks properly.
 
Old 06-20-2020, 03:03 AM   #4
doru
Member
 
Registered: Sep 2008
Distribution: Ubuntu 8.04 LTS Server
Posts: 138

Original Poster
Rep: Reputation: 19
Quote:
Originally Posted by MadeInGermany View Post
I think that only du can report the allocated blocks properly.
stat, ls -l and du are fully coherent on this.
 
Old 06-20-2020, 03:02 PM   #5
shruggy
Senior Member
 
Registered: Mar 2020
Posts: 3,670

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

Last edited by shruggy; 06-20-2020 at 03:15 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What does 'IO Block' mean in the out put of stat command hilou Linux - Newbie 9 11-18-2013 08:25 PM
[SOLVED] hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) is referenced by DSO harig Programming 1 03-28-2013 06:34 AM
Minimum file size to report a size in vsftpd log anon091 Linux - Server 1 10-12-2011 06:24 PM
[SOLVED] gcc linker error - hidden symbol `stat' in /usr/lib/libc_nonshared.a(stat.oS) chaosless Linux - Software 1 09-17-2009 12:33 PM
Linux stat to Windows Stat sridurai Programming 3 09-24-2004 04:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:18 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration