cat /proc/mounts //显示已加载的文件系统
mountPath //你自己定义的挂载路径
string cmd ="cat /proc/mounts | awk -F' ' '$2==\"" + mountPath + "\"'"; //判断mountPath是否挂载上
string result=ExecuteCommand(cmd);
string ExecuteCommand(const string command)
{
FILE *fp;
char *buffer = (char *)malloc(1024*1024);
string result;
if (buffer == NULL)
{
cout << "ExecuteCommand error : Memory allocation failure." << endl;
return "";
}
memset(buffer,0,1024*1024);
fp = popen(command.data(),"r");
if (fp != NULL)
{
int size = fread(buffer,1,1024*1024,fp);
if (size > 0)
{
result = buffer;
}
else
{
result = "";
}
pclose(fp);
free(buffer);
}
else
{
cout << "the command maybe error!" << endl;
free(buffer);
result = "";
}
return result;
}