From 90b819c6d832046840018ff08b9bc5d0e3b69c37 Mon Sep 17 00:00:00 2001
From: Laurent Bercot
- int lock_ex (int fd)
-Gets an exclusive advisory lock on fd. fd must point to
-a regular file, open for writing. Blocks until the lock can be obtained.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
-
- int lock_exnb (int fd)
-Gets an exclusive advisory lock on fd. fd must point to
-a regular file, open for writing.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails. If the lock
-is held and the function would block, it immediately returns with -1 EWOULDBLOCK.
-
- int lock_sh (int fd)
-Gets a shared advisory lock on fd. fd must point to
-a regular file, open for reading. Blocks until the lock can be obtained.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
-
- int lock_shnb (int fd)
-Gets a shared advisory lock on fd. fd must point to
-a regular file, open for reading.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails. If the lock
-is held and the function would block, it immediately returns with -1 EWOULDBLOCK.
+ int fd_lock (int fd, int w, int nb)
+Gets an advisory lock on fd: shared if w is
+zero, exclusive otherwise. fd must point to
+a regular file, open for writing or reading depending on whether
+you want an exclusive lock or not. If nb is zero, the
+function blocks until the lock can be obtained; otherwise it
+returns 0 immediately. On success, the function returns 1 ; it
+returns 0 if it cannot take the lock, or -1 (and sets errno) if
+an error occurs.
- int lock_un (int fd)
+ void fd_unlock (int fd)
Releases a previously held lock on fd.
-Returns 0 if it succeeds, or -1 (and sets errno) if it fails.
- void lock_unx (int fd)
-Like lock_un, but without a return code and without
-modifying errno.
+ int fd_islocked (int fd)
+Returns 1 if a lock is currently held on fd, 0 otherwise.
+Returns -1 (and sets errno) if an error occurs.
-- cgit v1.2.3