summaryrefslogtreecommitdiff
path: root/openbsd-compat/bsd-flock.c
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@dtucker.net>2018-02-26 14:37:06 +1100
committerDarren Tucker <dtucker@dtucker.net>2018-02-26 14:37:06 +1100
commitcd3ab57f9b388f8b1abf601dc4d78ff82d83b75e (patch)
tree6fd98c6a6639d885271b66a27c43c0420755e756 /openbsd-compat/bsd-flock.c
parentb087998d1ba90dd1ddb6bfdb17873dc3e7392798 (diff)
Hook up flock() compat code.
Also a couple of minor changes: fail if we can't lock instead of silently succeeding, and apply a couple of minor style fixes.
Diffstat (limited to 'openbsd-compat/bsd-flock.c')
-rw-r--r--openbsd-compat/bsd-flock.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/openbsd-compat/bsd-flock.c b/openbsd-compat/bsd-flock.c
index 4a51ebe13..bf4d8a658 100644
--- a/openbsd-compat/bsd-flock.c
+++ b/openbsd-compat/bsd-flock.c
@@ -34,13 +34,15 @@
34 * Otherwise, don't do locking; just pretend success. 34 * Otherwise, don't do locking; just pretend success.
35 */ 35 */
36 36
37#include "nbtool_config.h" 37#include "includes.h"
38 38
39#if !HAVE_FLOCK 39#ifndef HAVE_FLOCK
40#include <errno.h> 40#include <errno.h>
41#include <fcntl.h> 41#include <fcntl.h>
42 42
43int flock(int fd, int op) { 43int
44flock(int fd, int op)
45{
44 int rc = 0; 46 int rc = 0;
45 47
46#if defined(F_SETLK) && defined(F_SETLKW) 48#if defined(F_SETLK) && defined(F_SETLKW)
@@ -69,6 +71,9 @@ int flock(int fd, int op) {
69 71
70 if (rc && (errno == EAGAIN)) 72 if (rc && (errno == EAGAIN))
71 errno = EWOULDBLOCK; 73 errno = EWOULDBLOCK;
74#else
75 rc = -1
76 errno = ENOSYS;
72#endif 77#endif
73 78
74 return rc; 79 return rc;