c - 如何检查给定文件夹是否为挂载点

标签 c linux-kernel mount mount-point

我必须使用 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/

相关文章:

c - 在我的 windows(xp) PC 中,哪里可以看到 malloc() 或任何库函数的源代码?

c - 当我不知道我需要的数据类型时我该怎么办?

c - 安装 sysfs 时 mount() 失败

c - 文件写入问题

sockets - 在自定义模块中调用 sock_release() 后内核卡住了

linux - 我可以使用 FreeBSD 内核制作操作系统吗?并仅构建与 Chromium-OS 相同的替代方案 HTML5

linux - 为什么 ISA 不需要 request_mem_region

apache - VirtualBox for Apache 中的共享文件夹

docker mount nfs with local_lock=all

c - 在C中用空字符分割字符串