X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=blobdiff_plain;f=lib%2Flockfile.c;fp=lib%2Flockfile.c;h=0000000000000000000000000000000000000000;hb=b7a32e2d73e3ab1add8208d3e157f7269a31ef4d;hp=185b3e1af7c0e9cdd884a427d3edae74144fa49e;hpb=ac902a8299ff4469b356836f431ead31c3377377;p=innduct.git diff --git a/lib/lockfile.c b/lib/lockfile.c deleted file mode 100644 index 185b3e1..0000000 --- a/lib/lockfile.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $Id: lockfile.c 6020 2002-12-20 00:19:58Z rra $ -** -** Lock a file or a range in a file. -** -** Provides inn_lock_file and inn_lock_range functions to lock or unlock a -** file or ranges within a file with a more convenient syntax than fcntl. -** Assume that fcntl is available. -*/ - -#include "config.h" -#include "clibrary.h" -#include -#include - -#include "libinn.h" - -bool -inn_lock_file(int fd, enum inn_locktype type, bool block) -{ - return inn_lock_range(fd, type, block, 0, 0); -} - -bool -inn_lock_range(int fd, enum inn_locktype type, bool block, off_t offset, - off_t size) -{ - struct flock fl; - int status; - - switch (type) { - case INN_LOCK_READ: fl.l_type = F_RDLCK; break; - case INN_LOCK_WRITE: fl.l_type = F_WRLCK; break; - default: - case INN_LOCK_UNLOCK: fl.l_type = F_UNLCK; break; - } - - do { - fl.l_whence = SEEK_SET; - fl.l_start = offset; - fl.l_len = size; - - status = fcntl(fd, block ? F_SETLKW : F_SETLK, &fl); - } while (status == -1 && errno == EINTR); - return (status != -1); -}