At the Carbon/CoreFoundation/Foundation layer and above, OSX presents the 
illusion that once mounted, automounted volumes are always mounted. They are 
not removed from the volume list if they are auto-unmounted because FSRefs and 
file reference URLs (which refer to volumes by ID) held by existing processes 
must continue to be valid.

You can tell if the automounted volume has been auto-unmounted by checking to 
see if it is a trigger again — at a low-level with getattrlist() by checking 
the DIR_MNTSTATUS_TRIGGER bit returned for the ATTR_DIR_MOUNTSTATUS attribute, 
or at a high level by checking the value of the NS/kCFURLIsMountTriggerKey 
resource property value. Accessing a path beyond a trigger of opening the 
trigger directory will cause the automount to be mounted.

However, that doesn’t really answer your question because a mounted network 
volume’s server might not be accessible, and mounting/remounting an automount 
might not find the file server. Other than pinging the server’s host, there’s 
not much you can do to tell the server is reachable (and even if it pings OK, 
the NFS server might not be responsive). Someone else might have more/better 
suggestions.

nfs.conf(5) lists lots of options that can change the way NFS mounts are 
handled. In particular, see the nfs.client.is_mobile option which attempts to 
make hard hangs on non-responsive NFS servers less likely.

- Jim

> On Feb 21, 2015, at 2:01 PM, Thomas Tempelmann <tempelm...@gmail.com> wrote:
> 
> (I realize this isn't really the best place to ask this question as it's 
> rather a user-level API question, not a filesys designer's question, but I 
> give it a try anyway because I didn't have luck finding answers elsewhere so 
> far.)
> 
> My question is: How can a user level app determine whether an automounted NFS 
> share is currently accessible or not?
> 
> E.g, if using the /etc/auto_master etc. files, to mount NFS file shares from 
> another computer under a private directory such as /mymounts/, how can I tell 
> if the mounts there, such as /mymounts/server1/ are currently accessible? I 
> know that the automount-daemon maintains a state about it because it prints 
> messages into the console when the mount becomes available or vanishes, and 
> often, when trying to access the mount's dir, it would simply return an empty 
> dir and/or some error state. Yet, sometimes, when I blindly attempt to read 
> the mount's dir, this causes an attempt to reach the (off-line) networked 
> computer, leading to a timeout after many seconds - and that's what I like to 
> avoid as it'll stall my app and cause all sorts of usability trouble.
> 
> Using lstat or looking at the flags from FSGetVolumeParms doesn't show me any 
> indication about this state.
> 
> How is that done, does anyone know?
> 
> I also asked the question on SO, if anyone likes to read or comment there:
> 
> http://stackoverflow.com/questions/28567054/ 
> <http://stackoverflow.com/questions/28567054/>
> 
> Thomas
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Filesystem-dev mailing list      (Filesystem-dev@lists.apple.com)
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/filesystem-dev/luther.j%40apple.com
> 
> This email sent to luthe...@apple.com

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Filesystem-dev mailing list      (Filesystem-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/filesystem-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to