LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Stat output problem (https://www.linuxquestions.org/questions/linux-newbie-8/stat-output-problem-4175421247/)

mmhs 08-09-2012 01:04 PM

Stat output problem
 
hi guys

i got confused about stat output

stat manual says

File : Size in Bytes
Blocks : Number of blocks used
IO Block : Size in bytes of every block.

when i use stat command for passwd file it says

Code:

~#stat /etc/passwd
 
File: `/etc/passwd'
Size: 999              Blocks: 8          IO Block: 4096  regular file
Device: ca00h/51712d        Inode: 845        Links: 1
Access: (0644/-rw-r--r--)  Uid: (    0/    root)  Gid: (    0/    root)
Access: 2011-05-26 12:14:41.000000000 +0200
Modify: 2011-05-26 12:14:41.000000000 +0200
Change: 2011-05-26 12:14:41.000000000 +0200

size is 999 bytes and every block is 4096 bytes how can this file use 8 blocks ???

8 blocks === 8 * 4096 = 32768

file size should be 32769 bytes to use 8 blocks !!

Kustom42 08-09-2012 02:49 PM

IO Block sizes are usually 4096, it has to do with the way hardware works. Heres a good article that should explain everything to you:

http://www.linuxintro.org/wiki/Block...nd_block_sizes

If you have more questions after that juts let us know.

mmhs 08-09-2012 10:20 PM

Quote:

Originally Posted by Kustom42 (Post 4750205)
IO Block sizes are usually 4096, it has to do with the way hardware works. Heres a good article that should explain everything to you:

http://www.linuxintro.org/wiki/Block...nd_block_sizes

If you have more questions after that juts let us know.

thx man

but i'm of the opinion for store a file with 999 bytes you need just one block . why it his example the file with 999 bytes needs 8 blocks ?????

mmhs 08-10-2012 11:30 AM

no one ?????

Kustom42 08-10-2012 04:44 PM

8 bit rule, everything is in eights.

rknichols 08-11-2012 11:21 AM

Quote:

Originally Posted by mmhs (Post 4750105)
hi guys

i got confused about stat output

stat manual says

File : Size in Bytes
Blocks : Number of blocks used
IO Block : Size in bytes of every block.
Code:

Size: 999              Blocks: 8          IO Block: 4096  regular file

I don't know where you found that "stat manual," but what you quoted is not correct. "Blocks" is reporting the number of 512B blocks allocated, and "IO Block" is reporting the file system's blocksize. What you have is 1 filesystem block (the minimum allocation), and that 4096B block uses 8 512B blocks on the device.


All times are GMT -5. The time now is 12:08 AM.