I like to get the properties for a specific file path's volume properties as shown by the mount
command, without using that command and instead calling the POSIX or related APIs.
When using the mount
command on OS X, I get a listing of all available volumes. man mount
points me to getfsent
, which returns a struct fstab
structure with the data I am interested in.
When I invoke getfsent()
the first time, I get the information about the root fs, i.e. for "/".
Problem is that I cannot get further mount points that way. man getfsent
suggests that I should simply repeatedly call it to learn of further mount points, but the next call returns NULL. I suspec that this function only returns what the actual "/etc/fstab" file contains, not the other volumes that OS X dynamically mounts later on.
But since the mount
command can list those additional vols, there must be a way. What is it? Alternatively, I might just look at the source code, but I cannot figure out in which of the many downloads available from opensource.apple.com it is included.
Update: For a solution to list all mounted volumes, see How to iterate all mounted file systems on OSX.
Turns out that, for learning the properties, such as file system type, of a particular file's volume, I can also call
statfs()
and read out thefstypename
field. That way, I don't have to iterate over the mounted file systems. I will edit the question accodingly now.