+ default:
+ adios(NULL, "Internal locking error: unsupported lock type used!");
+ }
+
+ return -1;
+}
+
+
+/*
+ * Routine to clean up the dot locking file
+ */
+
+static void
+lkclose_dot (int fd, const char *file)
+{
+ struct lockinfo lkinfo;
+
+ lockname (file, &lkinfo, 0); /* get name of lock file */
+#if !defined(HAVE_LIBLOCKFILE)
+ (void) m_unlink (lkinfo.curlock); /* remove lock file */
+#else
+ lockfile_remove(lkinfo.curlock);
+#endif /* HAVE_LIBLOCKFILE */
+ timerOFF (fd); /* turn off lock timer */
+}
+
+
+/*
+ * Open and lock a file, using fcntl locking
+ */
+
+static int
+lkopen_fcntl(const char *file, int access, mode_t mode, int *failed_to_lock)
+{
+ int fd, i, saved_errno;
+ struct flock flk;
+
+ /*
+ * The assumption here is that if you open the file for writing, you
+ * need an exclusive lock.
+ */
+
+ for (i = 0; i < LOCK_RETRIES; i++) {
+ if ((fd = open(file, access, mode)) == -1)