1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
* rquota_dispatch This file contains the function dispatch table.
*
* Authors: Donald J. Becker, <becker@super.org>
* Rick Sladkey, <jrs@world.std.com>
* Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
* Olaf Kirch, <okir@monad.swb.de>
*
* This software may be used for any purpose provided
* the above copyright notice is retained. It is supplied
* as is, with no warranty expressed or implied.
*/
#include "rquotad.h"
#include "logging.h"
#include "rpcmisc.h"
/*
* These are the global variables that hold all argument and result data.
*/
union rquotad_arguments argument;
union rquotad_results result;
/*
* This is a dispatch table to simplify error checking,
* and supply return attributes for NFS functions.
*/
#ifdef __STDC__
#define CONCAT(a,b) a##b
#define CONCAT3(a,b,c) a##b##c
#define STRING(a) #a
#else
#define CONCAT(a,b) a/**/b
#define CONCAT3(a,b,c) a/**/b/**/c
#define STRING(a) "a"
#endif
#define table_ent(res_type, arg_type, funct) { \
sizeof(res_type), sizeof(arg_type), \
(xdrproc_t) CONCAT(xdr_,res_type), \
(xdrproc_t) CONCAT(xdr_,arg_type), \
(void *(*)()) CONCAT3(rquota_,funct,_1_svc), \
STRING(funct), CONCAT(pr_,arg_type) \
}
#define nil void
#define xdr_nil xdr_void
#define pr_nil pr_void
#define pr_char pr_void
struct dispatch_entry {
int res_size, arg_size; /* sizeof the res/arg structs */
xdrproc_t xdr_result;
xdrproc_t xdr_argument;
void *(*funct)(); /* function handler */
char *name; /* name of function */
char *(*log_print)(); /* ptr to debug handler */
};
static _PRO(char *pr_void, (void) );
static _PRO(char *pr_getquota_args, (getquota_args *argp) );
static struct dispatch_entry dtable[] = {
table_ent(nil,nil,null), /* NULL */
table_ent(getquota_rslt,getquota_args,getquota),/* GETQUOTA */
table_ent(getquota_rslt,getquota_args,getactivequota),
/* GETACTIVEQUOTA */
};
/*
* The main dispatch routine.
*/
void rquota_dispatch(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
{
unsigned int proc_index;
struct dispatch_entry *dent;
union rquotad_results *resp;
proc_index = rqstp->rq_proc;
_rpcsvcdirty = 1;
if (proc_index >= (sizeof(dtable) / sizeof(dtable[0]))) {
svcerr_noproc(transp);
goto done;
}
dent = &dtable[proc_index];
memset(&argument, 0, dent->arg_size);
if (!svc_getargs(transp, dent->xdr_argument, &argument)) {
svcerr_decode(transp);
goto done;
}
/* Clear the result structure. */
memset(&result, 0, dent->res_size);
/* Log the call. */
if (logging_enabled(D_CALL))
log_call(rqstp, dent->name, dent->log_print(&argument));
/* Do the function call itself. */
resp = (*dent->funct) (&argument, rqstp);
if (!svc_sendreply(transp, dent->xdr_result, (caddr_t) resp)) {
svcerr_systemerr(transp);
}
if (!svc_freeargs(transp, dent->xdr_argument, &argument)) {
Dprintf(L_ERROR, "unable to free RPC arguments, exiting\n");
exit(1);
}
done:
_rpcsvcdirty = 0;
}
/*
* Functions for debugging output.
*/
static char *pr_void()
{
return ("");
}
static char *pr_getquota_args(argp)
getquota_args *argp;
{
static char buf[1200];
char *path = argp->gqa_pathp;
if (strlen(path) > 1024) {
Dprintf(L_WARNING, "giant pathname in getquota call: %s\n",
path);
path = "<giant path>";
}
sprintf(buf, "uid %d path %s", argp->gqa_uid, path);
return buf;
}
|