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