utils: Return status 0 on clean exits
[nfs-utils.git] / utils / mountd / mount_dispatch.c
1 /*
2  * mount_dispatch       This file contains the function dispatch table.
3  *
4  * Copyright (C) 1995 Olaf Kirch <okir@monad.swb.de>
5  */
6
7 #ifdef HAVE_CONFIG_H
8 #include <config.h>
9 #endif
10
11 #ifdef HAVE_TCP_WRAPPER
12 #include "tcpwrapper.h"
13 #endif
14
15 #include "mountd.h"
16 #include "rpcmisc.h"
17
18 /*
19  * Procedures for MNTv1
20  */
21 static struct rpc_dentry mnt_1_dtable[] = {
22         dtable_ent(mount_null,1,void,void),             /* NULL */
23         dtable_ent(mount_mnt,1,dirpath,fhstatus),       /* MNT */
24         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
25         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
26         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
27         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
28         dtable_ent(mount_exportall,1,void,exports),     /* EXPORTALL */
29 };
30
31 /*
32  * Procedures for MNTv2
33  */
34 static struct rpc_dentry mnt_2_dtable[] = {
35         dtable_ent(mount_null,1,void,void),             /* NULL */
36         dtable_ent(mount_mnt,1,dirpath,fhstatus),       /* MNT */
37         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
38         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
39         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
40         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
41         dtable_ent(mount_exportall,1,void,exports),     /* EXPORTALL */
42         dtable_ent(mount_pathconf,2,dirpath,ppathcnf),  /* PATHCONF */
43 };
44
45 /*
46  * Procedures for MNTv3
47  */
48 static struct rpc_dentry mnt_3_dtable[] = {
49         dtable_ent(mount_null,1,void,void),             /* NULL */
50         dtable_ent(mount_mnt,3,dirpath,mountres3),      /* MNT */
51         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
52         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
53         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
54         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
55 };
56
57 #define number_of(x)    (sizeof(x)/sizeof(x[0]))
58
59 static struct rpc_dtable        dtable[] = {
60         { mnt_1_dtable,         number_of(mnt_1_dtable) },
61         { mnt_2_dtable,         number_of(mnt_2_dtable) },
62         { mnt_3_dtable,         number_of(mnt_3_dtable) },
63 };
64
65 /*
66  * The main dispatch routine.
67  */
68 void
69 mount_dispatch(struct svc_req *rqstp, SVCXPRT *transp)
70 {
71         union mountd_arguments  argument;
72         union mountd_results    result;
73
74 #ifdef HAVE_TCP_WRAPPER
75         /* remote host authorization check */
76         if (!check_default("mountd", nfs_getrpccaller(transp), MOUNTPROG)) {
77                 svcerr_auth (transp, AUTH_FAILED);
78                 return;
79         }
80 #endif
81
82         rpc_dispatch(rqstp, transp, dtable, number_of(dtable),
83                         &argument, &result);
84 }