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.