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.
This commit is contained in:
Darren Tucker 2018-02-26 14:37:06 +11:00
parent b087998d1b
commit cd3ab57f9b
4 changed files with 18 additions and 4 deletions

View File

@ -1723,6 +1723,7 @@ AC_CHECK_FUNCS([ \
explicit_bzero \
fchmod \
fchown \
flock \
freeaddrinfo \
freezero \
fstatfs \

View File

@ -16,7 +16,7 @@ LDFLAGS=-L. @LDFLAGS@
OPENBSD=base64.o basename.o bcrypt_pbkdf.o bindresvport.o blowfish.o daemon.o dirname.o fmt_scaled.o getcwd.o getgrouplist.o getopt_long.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o pwcache.o readpassphrase.o reallocarray.o realpath.o recallocarray.o rresvport.o setenv.o setproctitle.o sha1.o sha2.o rmd160.o md5.o sigact.o strcasestr.o strlcat.o strlcpy.o strmode.o strnlen.o strptime.o strsep.o strtonum.o strtoll.o strtoul.o strtoull.o timingsafe_bcmp.o vis.o blowfish.o bcrypt_pbkdf.o explicit_bzero.o freezero.o
COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-getpagesize.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-malloc.o bsd-setres_id.o bsd-signal.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xcrypt.o kludge-fd_set.o
COMPAT=arc4random.o bsd-asprintf.o bsd-closefrom.o bsd-cygwin_util.o bsd-getpeereid.o getrrsetbyname-ldns.o bsd-err.o bsd-flock.o bsd-getpagesize.o bsd-misc.o bsd-nextstep.o bsd-openpty.o bsd-poll.o bsd-malloc.o bsd-setres_id.o bsd-signal.o bsd-snprintf.o bsd-statvfs.o bsd-waitpid.o fake-rfc2553.o openssl-compat.o xcrypt.o kludge-fd_set.o
PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-net.o port-uw.o

View File

@ -34,13 +34,15 @@
* Otherwise, don't do locking; just pretend success.
*/
#include "nbtool_config.h"
#include "includes.h"
#if !HAVE_FLOCK
#ifndef HAVE_FLOCK
#include <errno.h>
#include <fcntl.h>
int flock(int fd, int op) {
int
flock(int fd, int op)
{
int rc = 0;
#if defined(F_SETLK) && defined(F_SETLKW)
@ -69,6 +71,9 @@ int flock(int fd, int op) {
if (rc && (errno == EAGAIN))
errno = EWOULDBLOCK;
#else
rc = -1
errno = ENOSYS;
#endif
return rc;

View File

@ -145,4 +145,12 @@ int raise(int);
pid_t getsid(pid_t);
#endif
#ifndef HAVE_FLOCK
# define LOCK_SH 0x01
# define LOCK_EX 0x02
# define LOCK_NB 0x04
# define LOCK_UN 0x08
int flock(int, int);
#endif
#endif /* _BSD_MISC_H */