gpt4 book ai didi

c - 获取存储文件的文件系统类型

转载 作者:太空狗 更新时间:2023-10-29 15:50:58 25 4
gpt4 key购买 nike

如何确定存储文件的文件系统类型?我可能有文件名,或者稍后,只有一个描述符。

一开始我很乐意使用脚本,但希望知道如何使用 C 的系统调用来完成它。

最佳答案

在命令行/脚本中,您可以使用stat:

$ stat -f -c "%T" someFileOnExt2Ext3
ext2/ext3

$ stat -f -c "%T" someFileOnNFS
nfs

这最终会导致 statfs(2)系统调用:

int statfs(const char *path, struct statfs *buf);

The function statfs() returns information about a mounted file system. path is the pathname of any file within the mounted file system, buf is a pointer to a statfs structure.

关于c - 获取存储文件的文件系统类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14849796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com