1

I'm writing some software that can ideally mount and unmount multiple Network File System (NFS) locations dynamically.

To avoid clashing with local names I plan on generating a new temporary dir under /private/var/folders such as /private/var/folders/6l/jbv4dn11301f7t2wm1r3mqlr0000gp/T/temp_mount.RXArBC for each time I introduce a NFS share - in the hope that the OS can tidy up these folders on shutdown.

The worry I have is that for example, if I were to try to remove the folder before it was unmounted with something like rm -r /private/var/folders/6l/jbv4dn11301f7t2wm1r3mqlr0000gp/T/temp_mount.RXArBC - if the mount was not read-only, this would result in deleting the contents from the share (despite failing to delete the top-level folder as the mount service is presumably still holding a lock to it)!

I'm concerned the OS isn't expecting /private/var/folders to contain any mounts and thus pose a similar problem.

Can someone confirm how it is the OS will behave in this scenario? So far with my testing this hasn't happened, but I'm not sure this is indicative across the board for macOS users.

Another option I've considered is creating folders under somewhere like ~/Library/Application Support/MyAppDomain/MountDirs/ and performing tidy ups in my software as I go along, but I'm unsure how the OS will behave.

1

No.

This is a system directory that contains things like logs, databases, your sleep image, etc. It's not a directory that you should be mounting file shares to. The purpose of the /private directory has already be discussed in the following posts:

Even the automount service doesn't mount shares to that directory, it's mounted in /Volumes.

Your best bet would be to either mount the share in a shared user space (i.e. /Users/shared) or within the users own home directory.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .