【发布时间】:2016-06-03 11:36:27
【问题描述】:
我正在尝试打印当前 linux 分区的磁盘状态。使用以下 C 代码:
#include <stdio.h>
#include <stdlib.h>
#include <sys/statfs.h>
struct statfs S;
int main(int argc,char *argv[]){
int i = statfs("/dev/sda3",&S);
if (i!=0){
printf("File path error!!\n");
exit(0);
}
if(S.f_type == 0xEF53){
printf("The file system is ext_fs");
}
if (S.f_type == 0x4d44)
printf("The Partition is MS DOS super magic\n");
else
printf("Some other partition\n");
printf("Optimum transfer Blocks: %ld\n",S.f_bsize);
return 0;
**问题是if(S.f_type == 0xEF53) 行无法正常工作,即即使我通过/dev/sda4 分区(我的linux 分区ext4)条件返回false。
我搜索了很多,但无法解决问题。请在这里指导我......
编辑S.f_type的值为16914836
【问题讨论】:
-
你得到什么输出?你在
S.f_type中得到了什么价值? -
16914836。这就是我打印 S.f_type 时得到的结果。
-
你应该在你的问题中说清楚。