]> git.decadent.org.uk Git - nfs-utils.git/blobdiff - utils/lockd/lockd.c
Add option to specify directory to search for credentials cache files
[nfs-utils.git] / utils / lockd / lockd.c
index 05bc99938986879cfdd76b8cfeeb212ca02c1c16..71b31b0068c847ed522a41e1355d89b3370c2702 100644 (file)
@@ -6,10 +6,17 @@
  *
  */
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdio.h>
-#include "nfslib.h"
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <nfslib.h>
+
+
 
 static void    usage(const char *);
 
@@ -20,9 +27,21 @@ main(int argc, char **argv)
 
        if (argc > 1)
                usage (argv [0]);
-
-       if ((error = lockdsvc()) < 0)
-               perror("lockdsvc");
+       
+       if (chdir(NFS_STATEDIR)) {
+               fprintf(stderr, "%s: chdir(%s) failed: %s\n",
+                       argv [0], NFS_STATEDIR, strerror(errno));
+               exit(1);
+       }
+
+       if ((error = lockdsvc()) < 0) {
+               if (errno == EINVAL)
+                       /* Ignore EINVAL since kernel may start
+                          lockd automatically. */
+                       error = 0;
+               else
+                       perror("lockdsvc");
+       }
 
        return (error != 0);
 }