0

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.

2
  • 1
    Maybe using dtruss with mount can help to identify the syscall you need. Commented Dec 22, 2016 at 15:08
  • A starting point is to download FSMegaInfoGUI. The software is old (based on some Apple source code) but is still working. Commented Dec 22, 2016 at 15:24

1 Answer 1

0

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 the fstypename field. That way, I don't have to iterate over the mounted file systems. I will edit the question accodingly now.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.