-
Notifications
You must be signed in to change notification settings - Fork 0
/
mount_svc.c
101 lines (87 loc) · 2.24 KB
/
mount_svc.c
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
#include "stdio.h"
#include "rpc/rpc.h"
#include "mount.h"
static void mountprog_1();
mountd_main(sock)
{
SVCXPRT *transp;
(void)pmap_unset(MOUNTPROG, MOUNTVERS);
transp = svcudp_create(sock, 4096, 4096);
if (transp == NULL) {
(void)fprintf(stderr, "cannot create udp service.\n");
exit(1);
}
if (!svc_register(transp, MOUNTPROG, MOUNTVERS, mountprog_1, IPPROTO_UDP)) {
(void)fprintf(stderr, "unable to register (MOUNTPROG, MOUNTVERS, udp).\n");
exit(1);
}
svc_run();
(void)fprintf(stderr, "svc_run returned\n");
exit(1);
}
static void
mountprog_1(rqstp, transp)
struct svc_req *rqstp;
SVCXPRT *transp;
{
union {
dirpath mountproc_mnt_1_arg;
dirpath mountproc_umnt_1_arg;
} argument;
char *result;
bool_t (*xdr_argument)(), (*xdr_result)();
char *(*local)();
switch (rqstp->rq_proc) {
case MOUNTPROC_NULL:
xdr_argument = xdr_void;
xdr_result = xdr_void;
local = (char *(*)()) mountproc_null_1;
break;
case MOUNTPROC_MNT:
xdr_argument = xdr_dirpath;
xdr_result = xdr_fhstatus;
local = (char *(*)()) mountproc_mnt_1;
break;
case MOUNTPROC_DUMP:
xdr_argument = xdr_void;
xdr_result = xdr_mountlist;
local = (char *(*)()) mountproc_dump_1;
break;
case MOUNTPROC_UMNT:
xdr_argument = xdr_dirpath;
xdr_result = xdr_void;
local = (char *(*)()) mountproc_umnt_1;
break;
case MOUNTPROC_UMNTALL:
xdr_argument = xdr_void;
xdr_result = xdr_void;
local = (char *(*)()) mountproc_umntall_1;
break;
case MOUNTPROC_EXPORT:
xdr_argument = xdr_void;
xdr_result = xdr_exports;
local = (char *(*)()) mountproc_export_1;
break;
case MOUNTPROC_EXPORTALL:
xdr_argument = xdr_void;
xdr_result = xdr_exports;
local = (char *(*)()) mountproc_exportall_1;
break;
default:
svcerr_noproc(transp);
return;
}
bzero((char *)&argument, sizeof(argument));
if (!svc_getargs(transp, xdr_argument, &argument)) {
svcerr_decode(transp);
return;
}
result = (*local)(&argument, rqstp);
if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
svcerr_systemerr(transp);
}
if (!svc_freeargs(transp, xdr_argument, &argument)) {
(void)fprintf(stderr, "unable to free arguments\n");
exit(1);
}
}