我必须使用 C 代码测试给定的文件夹路径是挂载点还是位于我的系统本地。
我在网上读到 /etc/mtab
文件有挂载点条目。我可以检查该文件,但它们是任何系统调用或任何检查安装点的函数。
我的内核版本是2.6.28.10
。
最佳答案
这些函数可用于访问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)
有关这些函数的更多详细信息,请参阅手册页。
关于c - 如何检查给定文件夹是否为挂载点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22218054/