Linux的函数来获取挂载点 [英] Linux function to get mount points
本文介绍了Linux的函数来获取挂载点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个函数(或接口,读写控制,网络链路等)的标准Linux库,将直接从内核返回当前坐骑没有解析的/ proc? strace的
ING mount命令,它看起来像它在/ proc文件解析
Is there a function (or interface; ioctl, netlink etc) in the standard Linux libs that will return the current mounts directly from the kernel without parsing /proc? strace
ing the mount command, it looks like it parses files in /proc
推荐答案
有没有,你会不会使用参阅getmntent
libc库调用的任何原因?我也知道这是不一样作为一个'都在同一个系统调用,但它应该让你得到相关的信息。
Is there any reason that you would not use the getmntent
libc library call? I do realize that it's not the same as an 'all in one' system call, but it should allow you to get the relevant information.
#include <stdio.h>
#include <stdlib.h>
#include <mntent.h>
int main(void)
{
struct mntent *ent;
FILE *aFile;
aFile = setmntent("/proc/mounts", "r");
if (aFile == NULL) {
perror("setmntent");
exit(1);
}
while (NULL != (ent = getmntent(aFile))) {
printf("%s %s\n", ent->mnt_fsname, ent->mnt_dir);
}
endmntent(aFile);
}
这篇关于Linux的函数来获取挂载点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文