Throughout the CoreFoundation framework source, POSIX filesystem API calls (e.g. open()
, stat()
, et al…) are wrapped in an idiom wherein a descriptor on /dev/autofs_nowait
is acquired – with open(…, 0)
– before the POSIX calls are made; afterwards the descriptor is close()
’d before the scope exits.
What is the benefit of doing this? What are the risks?
Does acquiring the
/dev/autofs_nowait
descriptor have any affect on, or is it effected by, flags to any thusly-wrappedopen()
calls (like e.g.O_NONBLOCK
)?/dev
on my machine, running OS X 10.10.5 has other “autofs” entries:… none of which have
man
pages available. If these file-like devices might offer benefits in this vein I would be interested to hear about their use as well, as it may pertain.
Addendum: I could not find much on this subject; a Google Plus post from 2011 claims that:
[t]his file is a special device that's monitored by the autofs filesystem implementation in the kernel. When opened, the autofs filesystem will not block that process on any I/O operations on an autofs file system.
I am not quite sure what that means (they were specifically talking about how launchd
works, FWIW) but I was curious about this myself, so I wrote a quick context-manager-y RAII struct to try it out – untargeted profiling shows tests with POSIX calls completing faster but within general hashmarks; I’ll investigate this tactic with a finer-toothed comb after I get more background on how it all works.