1、介绍/proc/filesystems
/proc/filesystems里存放着本台机器Linux系统支持的文件挂载系统,不同的linux系统可能会得到不同的结果。
2、简要代码
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static char chFstypeInfo[][10] =
{
{"ext3"},
{"ext2"},
{"vfat"},
{"fat"},
{"tntfs"},
{"ext4"},
{"ufsd"},
{"ntfs3g"},
{"fuseblk"}
};
int read_proc_filesystems()
{
int num = 0;
FILE * fp = NULL;
char chBuffer[1024]={0};
char *pchCmd = "cat /proc/filesystems";
int len = 0;
int i =0;
fp = popen(pchCmd,"r");
if (NULL == fp)
{
printf("popen %s r failed",pchCmd);
return -1;
}
memset(chBuffer,0,sizeof(chBuffer));
fread(chBuffer,sizeof(chBuffer) -1,1,fp);
if(strlen(chBuffer) == 0)
{
pclose(fp);
return -1;
}
pclose(fp);
num = sizeof(chFstypeInfo)/sizeof(chFstypeInfo[0]);
for(i = 0; i < num ; i++)
{
if(strstr(chBuffer,chFstypeInfo[i]) != NULL)
{
if(i == 3)
{
if(strstr(chBuffer," fat") == NULL) //与vfat区分开
{
continue;
}
}
printf("\n support filesystem[%s]\n",chFstypeInfo[i]);
}
}
}
int main()
{
read_proc_filesystems();
return 0;
}
运行结果:
本文永久更新地址://m.ajphoenix.com/linux/31364.html