Re: stat

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Aug 17, 2007 at 07:21:44PM +0530, Adil Mujeeb wrote:
> This is regarding the stat system call. Before asking the question, let me
> tell you the environment setup of my test machine.
> 
> I have kernel version 2.6.19 installed and my home partition is ext3 :
> 
> adil@Garfield:~> uname -a
> 
> Linux Garfield 2.6.19.2-smp #3 SMP Mon Mar 12 17:25:39 IST 2007 i686 i686
> i386 GNU/Linux
> 
> adil@Garfield:~> pwd
> 
> /home/adil
> 
> adil@Garfield:~> mount | grep home
> 
> /dev/sda5 on /home type ext3 (rw,acl,user_xattr)
> 
> If I want to see the file system status through stat command, it shows the
> following oputput:
> 
> adil@Garfield:~> stat -f .
>   File: "."
>     ID: 0        Namelen: 255     Type: ext2/ext3
> Block size: 4096       Fundamental block size: 4096
> Blocks: Total: 11266702   Free: 6086151    Available: 5513836
> Inodes: Total: 5723200    Free: 5473928
> 
> My first question: What is difference between "Block size" and "Fundamental
> block size"? I have not found these two values different?

No idea, stat(2) and statvfs(2) don't define such a thing. Look it up
in the stat(1) source.

> Suppose I have a directory /home/test
> 
> Garfield:/home # stat -f test/
>   File: "test/"
>     ID: 0        Namelen: 255     Type: ext2/ext3
> Block size: 4096       Fundamental block size: 4096
> Blocks: Total: 11266702   Free: 6086151    Available: 5513836
> Inodes: Total: 5723200    Free: 5473928
> 
> I mount it as nfs partition locally:
> 
> Garfield:/home # mount -t nfs localhost:/home/test /mnt/nfs
> Garfield:/home # mount | grep nfs
> nfsd on /proc/fs/nfsd type nfsd (rw)
> localhost:/home/test on /mnt/nfs type nfs (rw,addr=127.0.0.1)
> 
> Issued stat ?f command:
> 
> Garfield:/home # stat -f /mnt/test/
>   File: "/mnt/test/"
>     ID: 0        Namelen: 255     Type: reiserfs
                                          ^^^^^^^^
Something went wrong, I think you're looking at a different filesystem
here.

> Block size: 4096       Fundamental block size: 4096
> Blocks: Total: 2612479    Free: 817984     Available: 817984
> Inodes: Total: 0          Free: 0
> 
> Garfield:/home #
> 
> My assumption is that the calculation of Total/Free/Available blocks are
> based on 4KB (default value) irrespective of the Block size and Fundamental
> block size.

No, I don't see how you come to that conclusion. You've so far only
looked at filesystems with 4k blocksize. I suggest to create an ext3 fs
with a 1k blocksize and see what it says.

> Please correct me if I am wrong?
> 
> I have created 1 MB file :
> 
> adil@Garfield:~> la -al 1MB
> -rw-r--r-- 1 adil users 1048576 2007-08-17 19:02 1MB
> 
> adil@Garfield:~> stat 1MB
>   File: `1MB'
>   Size: 1048576         Blocks: 2056       IO Block: 4096   regular file
> Device: 805h/2053d      Inode: 691177      Links: 1
> Access: (0644/-rw-r--r--)  Uid: ( 1002/    adil)   Gid: (  100/   users)
> Access: 2007-08-17 19:02:00.000000000 +0530
> Modify: 2007-08-17 19:02:00.000000000 +0530
> Change: 2007-08-17 19:02:00.000000000 +0530
> 
> Increase the file size with 6 bytes
> 
> adil@Garfield:~> la -al 1MB
> -rw-r--r-- 1 adil users 1048582 2007-08-17 19:03 1MB
> 
> adil@Garfield:~> stat 1MB
>   File: `1MB'
>   Size: 1048582         Blocks: 2064       IO Block: 4096   regular file
> Device: 805h/2053d      Inode: 691177      Links: 1
> Access: (0644/-rw-r--r--)  Uid: ( 1002/    adil)   Gid: (  100/   users)
> Access: 2007-08-17 19:03:01.000000000 +0530
> Modify: 2007-08-17 19:03:11.000000000 +0530
> Change: 2007-08-17 19:03:11.000000000 +0530
> 
> Now the number of blocks increase with 8 i.e. 512*8=4096. Does it mean,
> minimum number of block should be allocated will be 8 irrespective of IO
> Block size and system architecture?

The "blocks" count also accounts for the file metadata. Ext[23] use
block lists and need to store things like the indirect, double
indirect, and triple indirect blocks.

> Also is this 4096 figure related to the system Page size or anything else?

Right now Linux can only work with block sizes <= pagesize which
happens to be 4k on most architectures. Work is underway to allow
larger blocksizes.


Erik

- -- 
They're all fools. Don't worry. Darwin may be slow, but he'll
eventually get them. -- Matthew Lammers in alt.sysadmin.recovery
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFGxa/s/PlVHJtIto0RAqvQAJwJRzESWKs6H1yLCfpwdj2Q4kLBlwCfRc/9
gOJDfpAYLbsyPlM0QVf8CuM=
=/cPX
-----END PGP SIGNATURE-----

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux