[CentOS] Issues with stat() call on CentOS5 vs CentOS4

Fri Dec 10 17:23:37 UTC 2010
Dougal Ballantyne <dougal.lists at gmail.com>

Dear CentOS,

I have recently upgraded several servers from CentOS4 to CentOS5 and I am
noticing a strange change to the stat() call. I have written a very
small program to test and show the behavior. I am calling stat()
against a file which is exported from my NAS and mounted with 32k
read/write sizes.

[dougalb at centos4 tmp]$ cat my_stat.c
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>

int main(int argc, char **argv)
{
   if(argc != 2)
       return 1;

   struct stat fileStat;
   if(stat(argv[1],&fileStat) < 0)
       return 1;

   printf("Block size: \t\t%d\n",fileStat.st_blksize);

   return 0;
}

[dougalb at centos4 tmp]$
[dougalb at centos4 tmp]$ gcc -o my_stat.exe my_stat.c
[dougalb at centos4 tmp]$
[dougalb at centos4 tmp]$ ./my_stat.exe /mnt/nas/testfile
Block size:             32768
[dougalb at centos4 tmp]$
[dougalb at centos4 tmp]$ cat /etc/redhat-release
CentOS release 4.7 (Final)
[dougalb at centos4 tmp]$

[dougalb at centos5 tmp]$ ./my_stat.exe /mnt/nas/testfile
Block size:             4096
[dougalb at centos5 tmp]$
[dougalb at centos5 tmp]$ cat /etc/redhat-release
CentOS release 5.5 (Final)
[dougalb at centos5 tmp]$

On CentOS5 it is reporting 4k block sizes when it should report 32k. Has
anyone seen this or aware of what is causing this change in behavior?

Kind regards,

Dougal