Commit | Line | Data |
---|---|---|
d848bc15 | 1 | /* |
d848bc15 KM |
2 | * Copyright (c) 1989 Jan-Simon Pendry |
3 | * Copyright (c) 1989 Imperial College of Science, Technology & Medicine | |
12a3ab7b KB |
4 | * Copyright (c) 1989, 1993 |
5 | * The Regents of the University of California. All rights reserved. | |
d848bc15 KM |
6 | * |
7 | * This code is derived from software contributed to Berkeley by | |
8 | * Jan-Simon Pendry at Imperial College, London. | |
9 | * | |
10 | * %sccs.include.redist.c% | |
11 | * | |
12a3ab7b | 12 | * @(#)nfs_prot_svc.c 8.1 (Berkeley) %G% |
8d2991d5 | 13 | * |
332f0791 | 14 | * $Id: nfs_prot_svc.c,v 5.2.2.1 1992/02/09 15:09:30 jsp beta $ |
8d2991d5 | 15 | * |
d848bc15 KM |
16 | */ |
17 | ||
18 | #include "am.h" | |
19 | ||
20 | void nfs_program_2(rqstp, transp) | |
21 | struct svc_req *rqstp; | |
22 | SVCXPRT *transp; | |
23 | { | |
24 | union { | |
25 | nfs_fh nfsproc_getattr_2_arg; | |
26 | sattrargs nfsproc_setattr_2_arg; | |
27 | diropargs nfsproc_lookup_2_arg; | |
28 | nfs_fh nfsproc_readlink_2_arg; | |
29 | readargs nfsproc_read_2_arg; | |
30 | writeargs nfsproc_write_2_arg; | |
31 | createargs nfsproc_create_2_arg; | |
32 | diropargs nfsproc_remove_2_arg; | |
33 | renameargs nfsproc_rename_2_arg; | |
34 | linkargs nfsproc_link_2_arg; | |
35 | symlinkargs nfsproc_symlink_2_arg; | |
36 | createargs nfsproc_mkdir_2_arg; | |
37 | diropargs nfsproc_rmdir_2_arg; | |
38 | readdirargs nfsproc_readdir_2_arg; | |
39 | nfs_fh nfsproc_statfs_2_arg; | |
40 | } argument; | |
41 | char *result; | |
42 | bool_t (*xdr_argument)(), (*xdr_result)(); | |
43 | char *(*local)(); | |
44 | ||
45 | switch (rqstp->rq_proc) { | |
46 | case NFSPROC_NULL: | |
47 | xdr_argument = xdr_void; | |
48 | xdr_result = xdr_void; | |
49 | local = (char *(*)()) nfsproc_null_2; | |
50 | break; | |
51 | ||
52 | case NFSPROC_GETATTR: | |
53 | xdr_argument = xdr_nfs_fh; | |
54 | xdr_result = xdr_attrstat; | |
55 | local = (char *(*)()) nfsproc_getattr_2; | |
56 | break; | |
57 | ||
58 | case NFSPROC_SETATTR: | |
59 | xdr_argument = xdr_sattrargs; | |
60 | xdr_result = xdr_attrstat; | |
61 | local = (char *(*)()) nfsproc_setattr_2; | |
62 | break; | |
63 | ||
64 | case NFSPROC_ROOT: | |
65 | xdr_argument = xdr_void; | |
66 | xdr_result = xdr_void; | |
67 | local = (char *(*)()) nfsproc_root_2; | |
68 | break; | |
69 | ||
70 | case NFSPROC_LOOKUP: | |
71 | xdr_argument = xdr_diropargs; | |
72 | xdr_result = xdr_diropres; | |
73 | local = (char *(*)()) nfsproc_lookup_2; | |
74 | break; | |
75 | ||
76 | case NFSPROC_READLINK: | |
77 | xdr_argument = xdr_nfs_fh; | |
78 | xdr_result = xdr_readlinkres; | |
79 | local = (char *(*)()) nfsproc_readlink_2; | |
80 | break; | |
81 | ||
82 | case NFSPROC_READ: | |
83 | xdr_argument = xdr_readargs; | |
84 | xdr_result = xdr_readres; | |
85 | local = (char *(*)()) nfsproc_read_2; | |
86 | break; | |
87 | ||
88 | case NFSPROC_WRITECACHE: | |
89 | xdr_argument = xdr_void; | |
90 | xdr_result = xdr_void; | |
91 | local = (char *(*)()) nfsproc_writecache_2; | |
92 | break; | |
93 | ||
94 | case NFSPROC_WRITE: | |
95 | xdr_argument = xdr_writeargs; | |
96 | xdr_result = xdr_attrstat; | |
97 | local = (char *(*)()) nfsproc_write_2; | |
98 | break; | |
99 | ||
100 | case NFSPROC_CREATE: | |
101 | xdr_argument = xdr_createargs; | |
102 | xdr_result = xdr_diropres; | |
103 | local = (char *(*)()) nfsproc_create_2; | |
104 | break; | |
105 | ||
106 | case NFSPROC_REMOVE: | |
107 | xdr_argument = xdr_diropargs; | |
108 | xdr_result = xdr_nfsstat; | |
109 | local = (char *(*)()) nfsproc_remove_2; | |
110 | break; | |
111 | ||
112 | case NFSPROC_RENAME: | |
113 | xdr_argument = xdr_renameargs; | |
114 | xdr_result = xdr_nfsstat; | |
115 | local = (char *(*)()) nfsproc_rename_2; | |
116 | break; | |
117 | ||
118 | case NFSPROC_LINK: | |
119 | xdr_argument = xdr_linkargs; | |
120 | xdr_result = xdr_nfsstat; | |
121 | local = (char *(*)()) nfsproc_link_2; | |
122 | break; | |
123 | ||
124 | case NFSPROC_SYMLINK: | |
125 | xdr_argument = xdr_symlinkargs; | |
126 | xdr_result = xdr_nfsstat; | |
127 | local = (char *(*)()) nfsproc_symlink_2; | |
128 | break; | |
129 | ||
130 | case NFSPROC_MKDIR: | |
131 | xdr_argument = xdr_createargs; | |
132 | xdr_result = xdr_diropres; | |
133 | local = (char *(*)()) nfsproc_mkdir_2; | |
134 | break; | |
135 | ||
136 | case NFSPROC_RMDIR: | |
137 | xdr_argument = xdr_diropargs; | |
138 | xdr_result = xdr_nfsstat; | |
139 | local = (char *(*)()) nfsproc_rmdir_2; | |
140 | break; | |
141 | ||
142 | case NFSPROC_READDIR: | |
143 | xdr_argument = xdr_readdirargs; | |
144 | xdr_result = xdr_readdirres; | |
145 | local = (char *(*)()) nfsproc_readdir_2; | |
146 | break; | |
147 | ||
148 | case NFSPROC_STATFS: | |
149 | xdr_argument = xdr_nfs_fh; | |
150 | xdr_result = xdr_statfsres; | |
151 | local = (char *(*)()) nfsproc_statfs_2; | |
152 | break; | |
153 | ||
154 | default: | |
155 | svcerr_noproc(transp); | |
156 | return; | |
157 | } | |
158 | bzero((char *)&argument, sizeof(argument)); | |
159 | if (!svc_getargs(transp, xdr_argument, &argument)) { | |
160 | svcerr_decode(transp); | |
161 | return; | |
162 | } | |
163 | result = (*local)(&argument, rqstp); | |
164 | if (result != NULL && !svc_sendreply(transp, xdr_result, result)) { | |
165 | svcerr_systemerr(transp); | |
166 | } | |
167 | if (!svc_freeargs(transp, xdr_argument, &argument)) { | |
168 | plog(XLOG_FATAL, "unable to free rpc arguments in nfs_program_1"); | |
169 | going_down(1); | |
170 | } | |
171 | } | |
172 |