LinuxQuestions.org
Review your favorite Linux distribution.
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 08-09-2012, 02:04 PM   #1
mmhs
Member
 
Registered: Oct 2010
Posts: 99

Rep: Reputation: 1
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 !!

Last edited by mmhs; 08-09-2012 at 02:05 PM.
 
Old 08-09-2012, 03:49 PM   #2
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
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.
 
1 members found this post helpful.
Old 08-09-2012, 11:20 PM   #3
mmhs
Member
 
Registered: Oct 2010
Posts: 99

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by Kustom42 View Post
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 ?????
 
Old 08-10-2012, 12:30 PM   #4
mmhs
Member
 
Registered: Oct 2010
Posts: 99

Original Poster
Rep: Reputation: 1
no one ?????
 
Old 08-10-2012, 05:44 PM   #5
Kustom42
Senior Member
 
Registered: Mar 2012
Distribution: Red Hat
Posts: 1,604

Rep: Reputation: 415Reputation: 415Reputation: 415Reputation: 415Reputation: 415
8 bit rule, everything is in eights.
 
Old 08-11-2012, 12:21 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: CentOS
Posts: 3,622

Rep: Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577Reputation: 1577
Quote:
Originally Posted by mmhs View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[SOLVED] stat output to value t.othoneos Linux - Newbie 4 01-04-2012 06:48 AM
[SOLVED] Unexpected output from stat --format %h catkin Linux - Software 2 03-07-2010 04:00 AM
understanding stat() output TheIndependentAquarius Programming 5 02-23-2010 01:37 AM
Stat command output description jackloo Linux - Newbie 2 09-28-2007 09:31 AM
Cannot stat Input/Output error cygnus-x1 Linux - General 5 08-16-2006 10:48 AM

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

All times are GMT -5. The time now is 08:23 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration