2012-05-02 100 views
1

任何人都可以在此代碼中找出問題。 問題是它顯示所有路徑名相同的輸出,即使它們具有不同的內容和不同的文件。顯示所有路徑名相同輸出的statfs

#include<stdio.h> 
#include<sys/stat.h> 
#include<unistd.h> 
#include<sys/types.h> 
#include<sys/vfs.h> 
int main(int argc,char *argv[]) 
{ 
    struct statfs sb; 
    if((statfs(argv[1],&sb))==0) 
    { 
      printf("optimal transfer blk size is %d\n",sb.f_bsize); 
      printf("total data blocks are %d\n",sb.f_blocks); 
      printf("free blocks in fs are %d\n",sb.f_bfree); 
      printf("total file nodes in fs are %d\n",sb.f_files); 
      printf("free file nodes in fs are %d\n",sb.f_ffree); 
    } 

}

[[email protected] ex4]$ ./a.out /home/testuser 
optimal transfer blk size is 4096 
total data blocks are 8819390 
free blocks in fs are 6771045 
total file nodes in fs are 2240224 
free file nodes in fs are 1927385 

[[email protected] ex4]$ ./a.out /home/testuser/harish 
optimal transfer blk size is 4096 
total data blocks are 8819390 
free blocks in fs are 6771034 
total file nodes in fs are 2240224 
free file nodes in fs are 1927386 

在此先感謝。

回答

1

statfs給出安裝的信息文件系統,而不是目錄。除非/home/testuser/harish是一個完全不同的文件系統(即,您已在該位置安裝了分區),否則預計會得到與/home/testuser完全相同的信息並且正常。

相關問題