]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/lockd/lockd.c
2001-05-28 H.J. Lu <hjl@lucon.org>
[nfs-utils.git] / utils / lockd / lockd.c
1 /*
2  * lockd
3  *
4  * This is the user level part of lockd. This is very primitive, because
5  * all the work is now done in the kernel module.
6  *
7  */
8
9 #include "config.h"
10
11 #include <stdio.h>
12 #include <unistd.h>
13 #include <string.h>
14 #include <errno.h>
15 #include "nfslib.h"
16
17 static void     usage(const char *);
18
19 int
20 main(int argc, char **argv)
21 {
22         int error;
23
24         if (argc > 1)
25                 usage (argv [0]);
26
27         if (chdir(NFS_STATEDIR)) {
28                 fprintf(stderr, "%s: chdir(%s) failed: %s\n",
29                         argv [0], NFS_STATEDIR, strerror(errno));
30                 exit(1);
31         }
32
33         if ((error = lockdsvc()) < 0) {
34                 if (errno == EINVAL)
35                         /* Ignore EINVAL since kernel may start
36                            lockd automatically. */
37                         error = 0;
38                 else
39                         perror("lockdsvc");
40         }
41
42         return (error != 0);
43 }
44
45 static void
46 usage(const char *prog)
47 {
48         fprintf(stderr, "usage:\n%s\n", prog);
49         exit(2);
50 }