BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / amd / rpcx / nfs_prot_svc.c
CommitLineData
d848bc15 1/*
d848bc15
KM
2 * Copyright (c) 1989 Jan-Simon Pendry
3 * Copyright (c) 1989 Imperial College of Science, Technology & Medicine
4 * Copyright (c) 1989 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Jan-Simon Pendry at Imperial College, London.
9 *
af359dea
C
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. Neither the name of the University nor the names of its contributors
23 * may be used to endorse or promote products derived from this software
24 * without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
27 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
29 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
30 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
36 * SUCH DAMAGE.
37 *
38 * @(#)nfs_prot_svc.c 5.3 (Berkeley) 5/12/91
39 *
40 * $Id: nfs_prot_svc.c,v 5.2.1.2 91/05/07 22:18:58 jsp Alpha $
d848bc15 41 *
d848bc15
KM
42 */
43
44#include "am.h"
45
46void nfs_program_2(rqstp, transp)
47struct svc_req *rqstp;
48SVCXPRT *transp;
49{
50 union {
51 nfs_fh nfsproc_getattr_2_arg;
52 sattrargs nfsproc_setattr_2_arg;
53 diropargs nfsproc_lookup_2_arg;
54 nfs_fh nfsproc_readlink_2_arg;
55 readargs nfsproc_read_2_arg;
56 writeargs nfsproc_write_2_arg;
57 createargs nfsproc_create_2_arg;
58 diropargs nfsproc_remove_2_arg;
59 renameargs nfsproc_rename_2_arg;
60 linkargs nfsproc_link_2_arg;
61 symlinkargs nfsproc_symlink_2_arg;
62 createargs nfsproc_mkdir_2_arg;
63 diropargs nfsproc_rmdir_2_arg;
64 readdirargs nfsproc_readdir_2_arg;
65 nfs_fh nfsproc_statfs_2_arg;
66 } argument;
67 char *result;
68 bool_t (*xdr_argument)(), (*xdr_result)();
69 char *(*local)();
70
71 switch (rqstp->rq_proc) {
72 case NFSPROC_NULL:
73 xdr_argument = xdr_void;
74 xdr_result = xdr_void;
75 local = (char *(*)()) nfsproc_null_2;
76 break;
77
78 case NFSPROC_GETATTR:
79 xdr_argument = xdr_nfs_fh;
80 xdr_result = xdr_attrstat;
81 local = (char *(*)()) nfsproc_getattr_2;
82 break;
83
84 case NFSPROC_SETATTR:
85 xdr_argument = xdr_sattrargs;
86 xdr_result = xdr_attrstat;
87 local = (char *(*)()) nfsproc_setattr_2;
88 break;
89
90 case NFSPROC_ROOT:
91 xdr_argument = xdr_void;
92 xdr_result = xdr_void;
93 local = (char *(*)()) nfsproc_root_2;
94 break;
95
96 case NFSPROC_LOOKUP:
97 xdr_argument = xdr_diropargs;
98 xdr_result = xdr_diropres;
99 local = (char *(*)()) nfsproc_lookup_2;
100 break;
101
102 case NFSPROC_READLINK:
103 xdr_argument = xdr_nfs_fh;
104 xdr_result = xdr_readlinkres;
105 local = (char *(*)()) nfsproc_readlink_2;
106 break;
107
108 case NFSPROC_READ:
109 xdr_argument = xdr_readargs;
110 xdr_result = xdr_readres;
111 local = (char *(*)()) nfsproc_read_2;
112 break;
113
114 case NFSPROC_WRITECACHE:
115 xdr_argument = xdr_void;
116 xdr_result = xdr_void;
117 local = (char *(*)()) nfsproc_writecache_2;
118 break;
119
120 case NFSPROC_WRITE:
121 xdr_argument = xdr_writeargs;
122 xdr_result = xdr_attrstat;
123 local = (char *(*)()) nfsproc_write_2;
124 break;
125
126 case NFSPROC_CREATE:
127 xdr_argument = xdr_createargs;
128 xdr_result = xdr_diropres;
129 local = (char *(*)()) nfsproc_create_2;
130 break;
131
132 case NFSPROC_REMOVE:
133 xdr_argument = xdr_diropargs;
134 xdr_result = xdr_nfsstat;
135 local = (char *(*)()) nfsproc_remove_2;
136 break;
137
138 case NFSPROC_RENAME:
139 xdr_argument = xdr_renameargs;
140 xdr_result = xdr_nfsstat;
141 local = (char *(*)()) nfsproc_rename_2;
142 break;
143
144 case NFSPROC_LINK:
145 xdr_argument = xdr_linkargs;
146 xdr_result = xdr_nfsstat;
147 local = (char *(*)()) nfsproc_link_2;
148 break;
149
150 case NFSPROC_SYMLINK:
151 xdr_argument = xdr_symlinkargs;
152 xdr_result = xdr_nfsstat;
153 local = (char *(*)()) nfsproc_symlink_2;
154 break;
155
156 case NFSPROC_MKDIR:
157 xdr_argument = xdr_createargs;
158 xdr_result = xdr_diropres;
159 local = (char *(*)()) nfsproc_mkdir_2;
160 break;
161
162 case NFSPROC_RMDIR:
163 xdr_argument = xdr_diropargs;
164 xdr_result = xdr_nfsstat;
165 local = (char *(*)()) nfsproc_rmdir_2;
166 break;
167
168 case NFSPROC_READDIR:
169 xdr_argument = xdr_readdirargs;
170 xdr_result = xdr_readdirres;
171 local = (char *(*)()) nfsproc_readdir_2;
172 break;
173
174 case NFSPROC_STATFS:
175 xdr_argument = xdr_nfs_fh;
176 xdr_result = xdr_statfsres;
177 local = (char *(*)()) nfsproc_statfs_2;
178 break;
179
180 default:
181 svcerr_noproc(transp);
182 return;
183 }
184 bzero((char *)&argument, sizeof(argument));
185 if (!svc_getargs(transp, xdr_argument, &argument)) {
186 svcerr_decode(transp);
187 return;
188 }
189 result = (*local)(&argument, rqstp);
190 if (result != NULL && !svc_sendreply(transp, xdr_result, result)) {
191 svcerr_systemerr(transp);
192 }
193 if (!svc_freeargs(transp, xdr_argument, &argument)) {
194 plog(XLOG_FATAL, "unable to free rpc arguments in nfs_program_1");
195 going_down(1);
196 }
197}
198