]> git.decadent.org.uk Git - nfs-utils.git/blob - utils/mountd/mount_dispatch.c
2000-08-25 Ion Badulescu <ionut@cs.columbia.edu>
[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 #include "config.h"
8
9 #ifdef HAVE_TCP_WRAPPER
10 #include "tcpwrapper.h"
11 #endif
12
13 #include "mountd.h"
14 #include "rpcmisc.h"
15
16 /*
17  * Procedures for MNTv1
18  */
19 static struct rpc_dentry mnt_1_dtable[] = {
20         dtable_ent(mount_null,1,void,void),             /* NULL */
21         dtable_ent(mount_mnt,1,dirpath,fhstatus),       /* MNT */
22         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
23         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
24         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
25         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
26         dtable_ent(mount_exportall,1,void,exports),     /* EXPORTALL */
27 };
28
29 /*
30  * Procedures for MNTv2
31  */
32 static struct rpc_dentry mnt_2_dtable[] = {
33         dtable_ent(mount_null,1,void,void),             /* NULL */
34         dtable_ent(mount_mnt,1,dirpath,fhstatus),       /* MNT */
35         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
36         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
37         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
38         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
39         dtable_ent(mount_exportall,1,void,exports),     /* EXPORTALL */
40         dtable_ent(mount_pathconf,2,dirpath,ppathcnf),  /* PATHCONF */
41 };
42
43 /*
44  * Procedures for MNTv3
45  */
46 static struct rpc_dentry mnt_3_dtable[] = {
47         dtable_ent(mount_null,1,void,void),             /* NULL */
48         dtable_ent(mount_mnt,3,dirpath,mountres3),      /* MNT */
49         dtable_ent(mount_dump,1,void,mountlist),        /* DUMP */
50         dtable_ent(mount_umnt,1,dirpath,void),          /* UMNT */
51         dtable_ent(mount_umntall,1,void,void),          /* UMNTALL */
52         dtable_ent(mount_export,1,void,exports),        /* EXPORT */
53 };
54
55 #define number_of(x)    (sizeof(x)/sizeof(x[0]))
56
57 static struct rpc_dtable        dtable[] = {
58         { mnt_1_dtable,         number_of(mnt_1_dtable) },
59         { mnt_2_dtable,         number_of(mnt_2_dtable) },
60         { mnt_3_dtable,         number_of(mnt_3_dtable) },
61 };
62
63 /*
64  * The main dispatch routine.
65  */
66 void
67 mount_dispatch(struct svc_req *rqstp, SVCXPRT *transp)
68 {
69         union mountd_arguments  argument;
70         union mountd_results    result;
71
72 #ifdef HAVE_TCP_WRAPPER
73         /* remote host authorization check */
74         if (!check_default("mountd", svc_getcaller(transp),
75                            rqstp->rq_proc, MOUNTPROG)) {
76                 svcerr_auth (transp, AUTH_FAILED);
77                 return;
78         }
79 #endif
80
81         rpc_dispatch(rqstp, transp, dtable, number_of(dtable),
82                         &argument, &result);
83 }