From: Charles S. <bas...@ch...> - 2012-06-25 17:39:21
|
On Jun 25, 2012, at 12:30 PM, Dave Vasilevsky wrote: > On Sun, Jun 24, 2012 at 3:46 PM, Charles Srstka > <bas...@ch...> wrote: >> You can do this >> by passing O_EXLOCK to the open() function. If you want open() to fail >> immediately if the file is already open instead of simply blocking until the >> file is available, then pass O_NONBLOCK as well. > > What's the advantage of this over the flock(2) advisory locks I > proposed? As far as I can tell they have the exact same behaviour on > Mac OS X, but flock() is cross-platform and will work on Linux and BSD > as well. > > -V They’re both equivalent; I believe that O_EXLOCK uses the advisory locks under the hood. I was thinking of a Mac-specific solution, since the posts I replied to were considered doing very Mac-specific IOKit things anyway. At the time I wrote that, your e-mail hadn’t posted to the list yet. I would think that images becoming mounted while SheepShaver is running would be less of a concern on other platforms which can’t normally mount Mac volumes, though. Charles |