0

我必须使用 c 代码测试给定的文件夹路径是安装点还是在我的系统本地。

我在网上读到该/etc/mtab文件有安装点的条目。我可以检查该文件,但它们是检查挂载点的任何系统调用或任何函数。

我的内核版本是2.6.28.10.

4

2 回答 2

0

在 linux 上,getmntent() 适用于解析 /etc/mtab。

于 2014-03-06T09:12:37.063 回答
0

这些函数可用于访问 mtab 文件的数据结构:

FILE * setmntent(const char *file, const char *mode)

int endmntent (FILE *stream)

struct mntent * getmntent (FILE *stream)

struct mntent * getmntent_r (FILE *stream, struct mentent *result, char *buffer, int bufsize)

int addmntent (FILE *stream, const struct mntent *mnt)

char * hasmntopt (const struct mntent *mnt, const char *opt)

有关这些函数的更多详细信息,请参阅手册页。

于 2014-03-06T09:21:00.470 回答