Possibly stupid question about flock on a vanilla 3.3 distribution

42 views
Skip to first unread message

David Parsons

unread,
Nov 17, 2017, 2:11:01 AM11/17/17
to minix3
Does it actually work?  I'm porting my MTA over to Minix (because why not) and the flock that's in the library doesn't seem to know about nonblocking locks:

  if I do flock(fd, LOCK_EX) followed by flock(another-fd-pointing-at-fd, LOCK_EX|LOCK_NB) the second lock succeeds (either in the same process or a different process) but if I go directly to fcntl and set write locks on a trivial region (SEEK_SET,0,1) with F_SETLKW followed by F_SETLK, the F_SETLK EAGAIN's out on me as expected.

   When I look at the flock source on github (@ https://github.com/0xffea/MINIX3/blob/master/lib/libc/sys-minix/flock.c) it looks like there's no way it will ever work, given that the flock #defines maps bizarrely to the fcntl defines (LOCK_EX == F_UNLCK, so an attempt to flock() a file and that the flock implementation attempts to lock a zero-length region (which even doing a fcntl fails.)

   Is the intent that flock() should not be used, or is it just bug in libc?


   -david parsons

Lionel Sambuc

unread,
Nov 21, 2017, 4:12:22 AM11/21/17
to min...@googlegroups.com
Dear David,


It is a bug, when code is imported, unavailable features are either not imported, or commented out, or if only a part is not supported, the most appropriate error code is returned for the missing part.


Kind regards,

Lionel
--
Sent from my phone
--
You received this message because you are subscribed to the Google Groups "minix3" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minix3+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages