linux - Linux 上的 getfsstat() 等效于什么?

标签 linux filesystems mount

问题说明了一切。我想要 C 函数调用返回已安装文件系统的列表以及相关信息,例如文件系统类型。

最佳答案

您正在寻找 getmntent 和其他 *mntent 函数系列。参见 manpage供进一步引用。

代码示例取自 here并略作修改。 /etc/mtab 是一个包含已安装文件系统列表的文件。

mounts = setmntent("/etc/mtab", "r");
while ( (ent = getmntent(mounts)) != NULL ){
    if (strcmp(ent->mnt_type, "iso9660") == 0)
       /* copy mount point to output */
       strcpy(retval[cd_count - 1], ent->mnt_dir);
    } /* if */
} /* while */
endmntent(mounts);

不幸的是,这些函数不在 POSIX 中。但是它们是在 glibc 中进行联机帮助页和实现的,所以我认为它们是比解析 /proc 更好的替代方法。

关于linux - Linux 上的 getfsstat() 等效于什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1934678/

相关文章:

linux - ftp 传输后 mp3 和 wav 文件播放断断续续/太快

linux - 通过shell脚本更改文件内容

linux - 在另一个声音文件中查找一个声音文件

linux - 为什么我们需要文件系统的目录结构?

linux - 如何使用 shell 脚本查找具有最大上下文长度的行号?

git - 如何从 NTFS(桌面)推送到 FAT32(USB)?

Linux 'find' 仅针对当前文件夹和指定文件夹

linux - 如何在Linux上将标签正确添加到AWS EBS卷设备的文件系统中?

linux - rsync 连接到服务器时挂载驱动器

google-cloud-platform - 在 Google Cloud Platform 中将永久性磁盘挂载到/home