2

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

fdh
  • 5,256
  • 13
  • 58
  • 101

1 Answers1

3

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.

Arkku
  • 41,011
  • 10
  • 62
  • 84
  • Thanks that answers everything except for Q1. Does the computer itself use f_bfree or f_bavail? For example if I access my harddrive through finder, it displays the amount of free space. Is that free space f_bfree or f_bavail? – fdh Feb 08 '12 at 02:04