Hi List,
May be this is not the right place to ask, but still I could not stop myself to post this under this list.
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?
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
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.
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?
Also is this 4096 figure related to the system Page size or anything else?