Search code examples
macosdarwin

Native API to mount network volumes


I'm looking for a native macOS API that would enable me to mount network volumes.

Specifically, I'm looking to do exactly what Finder (Cmd-K) does, including passing credentials separately from the URI and mountpoint creation under /Volumes without superuser access.

Currently I'm using mount_smbfs and mount_afp, but:

  • They require credentials to be encoded into the URI, and mount_afp doesn't work with unicode characters in password, even urlquoted
  • I have to create mountpoints as root first

Solution

  • You can use the NetFS framework and NetFSMountURLSync() or NetFSMountURLAsync(). The documentation is in the NetFS.h header file.