Using “statfs” on Mac OS X?

2019-07-16 15:04发布

I need to retrieve information about a hard disk and am using the statfs function to do so.

  • When your computer displays free space on the HD, does it use "free blocks" or "free blocks available to unpriveleged user"?
  • Does statfs work with SSDs?
  • How would the "path" to the main hard drive be stored? On windows it's generally C:, but I am new to OSX.

The man pages don't seem to provide a very comprehensive look of how statfs works.

Mac OSX Snowleopard using C/Objective-C. Xcode 3.2.6

1条回答
唯我独甜
2楼-- · 2019-07-16 15:10

1) Look at man statfs; the structure returned has both counts available (f_bfree and f_bavail).¹

2) Yes, it works on filesystems, not hard drives, so it doesn't matter what type of hard drive (if any) the filesystem is on.

3) /

¹ In case the first part of the question was not about what statfs returns but what “the computer” displays in general, I guess the answer depends on the program used to display the amount of free space. Compare the two values returned by statfs to those displayed by the program you are interested in.

查看更多
登录 后发表回答