2012-05-02 2 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과 똑같은 정보를 얻을 것으로 예상됩니다.

관련 문제