+
+static int intLock (int fd, int type, int cmd)
+{
+ struct flock area;
+ area.l_type = type;
+ area.l_whence = SEEK_SET;
+ area.l_len = area.l_start = 0L;
+ return fcntl (fd, cmd, &area);
+}
+
+int zebraLock (int fd, int wr)
+{
+#if 0
+ return intLock (fd, wr ? F_EXLCK : F_SHLCK, F_SETLKW);
+#else
+ return intLock (fd, wr ? F_WRLCK : F_RDLCK, F_SETLKW);
+#endif
+}
+
+int zebraLockNB (int fd, int wr)
+{
+#if 0
+ return intLock (fd, wr ? F_EXLCK : F_SHLCK, F_SETLK);
+#else
+ return intLock (fd, wr ? F_WRLCK : F_RDLCK, F_SETLK);
+#endif
+}
+
+int zebraUnlock (int fd)
+{
+ return intLock (fd, F_UNLCK, F_SETLKW);
+}