In order to have stats on a hardrive one can use the sys/statvfs
It takes either a path or a fd.
int statvfs(const char *path, struct statvfs *buf);
int fstatvfs(int fd, struct statvfs *buf);
In my application I am parsing /proc/diskstats which provide me with the device name (ex: sda1, sda2).
I don't know how to use that device name in order to get the same stats as the statvfs functions. What functions can be used?
读取/etc/mtab
并映射设备名称以安装路径。
To connect a device with where its mounted, look at mount
. The source for mount
should tell you how to find the path each device is mounted on. Then you can open the path and call statvfs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.