summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>2007-08-03 09:20:28 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>2007-08-03 09:20:28 +0000
commit0218a78e536da0b3ed59ae6029dde157ed059e71 (patch)
tree3598796cb686a56b76f45bc91d2aba51e78d1984 /libutil
parentab8064c95587c1dbdcb93e7d90e7c1cf2663a541 (diff)
downloadpw-darwin-0218a78e536da0b3ed59ae6029dde157ed059e71.tar.gz
pw-darwin-0218a78e536da0b3ed59ae6029dde157ed059e71.tar.zst
pw-darwin-0218a78e536da0b3ed59ae6029dde157ed059e71.zip
Back out previous commit until I figure out why my regression test fails.
Approved by: re (kensmith)
Diffstat (limited to 'libutil')
-rw-r--r--libutil/flopen.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/libutil/flopen.c b/libutil/flopen.c
index f285ac5..23742f7 100644
--- a/libutil/flopen.c
+++ b/libutil/flopen.c
@@ -43,7 +43,6 @@ flopen(const char *path, int flags, ...)
{
int fd, operation, serrno, trunc;
struct stat sb, fsb;
- struct flock lock;
mode_t mode;
#ifdef O_EXLOCK
@@ -59,11 +58,9 @@ flopen(const char *path, int flags, ...)
va_end(ap);
}
- lock.l_type = (flags & O_RDONLY) ? F_RDLCK : F_WRLCK;
- lock.l_start = 0;
- lock.l_whence = SEEK_SET;
- lock.l_len = 0;
- operation = (flags & O_NONBLOCK) ? F_SETLK : F_SETLKW;
+ operation = LOCK_EX;
+ if (flags & O_NONBLOCK)
+ operation |= LOCK_NB;
trunc = (flags & O_TRUNC);
flags &= ~O_TRUNC;
@@ -72,7 +69,7 @@ flopen(const char *path, int flags, ...)
if ((fd = open(path, flags, mode)) == -1)
/* non-existent or no access */
return (-1);
- if (fcntl(fd, operation, &lock) == -1) {
+ if (flock(fd, operation) == -1) {
/* unsupported or interrupted */
serrno = errno;
close(fd);