【发布时间】:2018-09-22 05:58:17
【问题描述】:
我想使用函数 API 而不是使用df shell 命令的输出来获取指定卷的已使用 inode 数量。
我查看了getattrlist 的man page,发现有以下属性,但也可能指的是硬链接,但它们指向的是现有的inode,我不想多统计一次。
ATTR_VOL_FILECOUNT A u_int32_t containing the number of files on the volume.
我还尝试运行dtruss df 并搜索检索该值的确切系统调用,但我无法找到它:
csops(0x872, 0x7, 0x7FFEEE4C8E80) = 0 0
sysctl([CTL_KERN, 14, 1, 2162, 0, 0] (4), 0x7FFEEE4C8FC8, 0x7FFEEE4C8FC0, 0x0, 0x0) = 0 0
csops(0x872, 0x7, 0x7FFEEE4C8770) = 0 0
getfsstat64(0x0, 0x0, 0x2) = 6 0
getfsstat64(0x7FFD41001600, 0x3B48, 0x2) = 6 0
getfsstat64(0x7FFD41001600, 0x3B48, 0x1) = 6 0
getrlimit(0x1008, 0x7FFEEE4C9EC0, 0x0) = 0 0
fstat64(0x1, 0x7FFEEE4C9ED8, 0x0) = 0 0
ioctl(0x1, 0x4004667A, 0x7FFEEE4C9F24) = 0 0
这是df 输出(注意使用的字段)
Filesystem 512-blocks Used Available Capacity iused ifree %iused Mounted on
/dev/disk1s1 976695384 757288824 211770792 79% 2000778 9223372036852775029 0% /
我在哪里可以找到 df 的源代码或其他 API 以完成此任务。
谢谢
【问题讨论】:
-
以
df打印的实际文本为例,会很方便。 -
@unwind,您好,感谢您的评论。添加了 df 输出
标签: c macos filesystems system-calls