2 ** Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
3 ** distribution information.
6 /* $Id: locklockf.c,v 1.4 2002/09/02 16:55:56 mrsam Exp $ */
11 #include <sys/types.h>
16 #include <sys/fcntl.h>
26 int ll_lockfd(int fd
, int ltype
, LL_OFFSET_TYPE start
, LL_OFFSET_TYPE len
)
30 if (ltype
& ll_whence_curpos
)
31 p
=lseek(fd
, start
, SEEK_CUR
);
32 else if (ltype
&& ll_whence_end
)
33 p
=lseek(fd
, start
, SEEK_END
);
34 else p
=lseek(fd
, start
, SEEK_SET
);
36 if (p
< 0) return (-1);
38 if (lockf(fd
, ltype
& ll_unlock
? F_ULOCK
:
39 ltype
& ll_wait
? F_LOCK
:F_TLOCK
, len
))
41 lseek(fd
, p
, SEEK_SET
);
44 lseek(fd
, SEEK_SET
, p
);