BSD 4_3_Net_2 release
[unix-history] / usr / src / usr.sbin / amd / rpcx / nfs_prot_xdr.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_xdr.c 5.3 (Berkeley) 5/12/91
39 *
40 * $Id: nfs_prot_xdr.c,v 5.2.1.2 91/05/07 22:18:59 jsp Alpha $
d848bc15 41 *
d848bc15
KM
42 */
43
44#include "am.h"
45
46
47#ifndef xdr_nfsstat
48bool_t
49xdr_nfsstat(xdrs, objp)
50 XDR *xdrs;
51 nfsstat *objp;
52{
53 if (!xdr_enum(xdrs, (enum_t *)objp)) {
54 return (FALSE);
55 }
56 return (TRUE);
57}
58#endif /* xdr_nfsstat */
59
60
61
62#ifndef xdr_ftype
63static bool_t
64xdr_ftype(xdrs, objp)
65 XDR *xdrs;
66 ftype *objp;
67{
68 if (!xdr_enum(xdrs, (enum_t *)objp)) {
69 return (FALSE);
70 }
71 return (TRUE);
72}
73#endif /* xdr_ftype */
74
75
76
77bool_t
78xdr_nfs_fh(xdrs, objp)
79 XDR *xdrs;
80 nfs_fh *objp;
81{
82 if (!xdr_opaque(xdrs, objp->data, NFS_FHSIZE)) {
83 return (FALSE);
84 }
85 return (TRUE);
86}
87
88
89
90
91static bool_t
92xdr_nfstime(xdrs, objp)
93 XDR *xdrs;
94 nfstime *objp;
95{
96 if (!xdr_u_int(xdrs, &objp->seconds)) {
97 return (FALSE);
98 }
99 if (!xdr_u_int(xdrs, &objp->useconds)) {
100 return (FALSE);
101 }
102 return (TRUE);
103}
104
105
106
107
108static bool_t
109xdr_fattr(xdrs, objp)
110 XDR *xdrs;
111 fattr *objp;
112{
113 if (!xdr_ftype(xdrs, &objp->type)) {
114 return (FALSE);
115 }
116 if (!xdr_u_int(xdrs, &objp->mode)) {
117 return (FALSE);
118 }
119 if (!xdr_u_int(xdrs, &objp->nlink)) {
120 return (FALSE);
121 }
122 if (!xdr_u_int(xdrs, &objp->uid)) {
123 return (FALSE);
124 }
125 if (!xdr_u_int(xdrs, &objp->gid)) {
126 return (FALSE);
127 }
128 if (!xdr_u_int(xdrs, &objp->size)) {
129 return (FALSE);
130 }
131 if (!xdr_u_int(xdrs, &objp->blocksize)) {
132 return (FALSE);
133 }
134 if (!xdr_u_int(xdrs, &objp->rdev)) {
135 return (FALSE);
136 }
137 if (!xdr_u_int(xdrs, &objp->blocks)) {
138 return (FALSE);
139 }
140 if (!xdr_u_int(xdrs, &objp->fsid)) {
141 return (FALSE);
142 }
143 if (!xdr_u_int(xdrs, &objp->fileid)) {
144 return (FALSE);
145 }
146 if (!xdr_nfstime(xdrs, &objp->atime)) {
147 return (FALSE);
148 }
149 if (!xdr_nfstime(xdrs, &objp->mtime)) {
150 return (FALSE);
151 }
152 if (!xdr_nfstime(xdrs, &objp->ctime)) {
153 return (FALSE);
154 }
155 return (TRUE);
156}
157
158
159
160
161static bool_t
162xdr_sattr(xdrs, objp)
163 XDR *xdrs;
164 sattr *objp;
165{
166 if (!xdr_u_int(xdrs, &objp->mode)) {
167 return (FALSE);
168 }
169 if (!xdr_u_int(xdrs, &objp->uid)) {
170 return (FALSE);
171 }
172 if (!xdr_u_int(xdrs, &objp->gid)) {
173 return (FALSE);
174 }
175 if (!xdr_u_int(xdrs, &objp->size)) {
176 return (FALSE);
177 }
178 if (!xdr_nfstime(xdrs, &objp->atime)) {
179 return (FALSE);
180 }
181 if (!xdr_nfstime(xdrs, &objp->mtime)) {
182 return (FALSE);
183 }
184 return (TRUE);
185}
186
187
188
189
190static bool_t
191xdr_filename(xdrs, objp)
192 XDR *xdrs;
193 filename *objp;
194{
195 if (!xdr_string(xdrs, objp, NFS_MAXNAMLEN)) {
196 return (FALSE);
197 }
198 return (TRUE);
199}
200
201
202
203
204bool_t
205xdr_nfspath(xdrs, objp)
206 XDR *xdrs;
207 nfspath *objp;
208{
209 if (!xdr_string(xdrs, objp, NFS_MAXPATHLEN)) {
210 return (FALSE);
211 }
212 return (TRUE);
213}
214
215
216
217
218bool_t
219xdr_attrstat(xdrs, objp)
220 XDR *xdrs;
221 attrstat *objp;
222{
223 if (!xdr_nfsstat(xdrs, &objp->status)) {
224 return (FALSE);
225 }
226 switch (objp->status) {
227 case NFS_OK:
228 if (!xdr_fattr(xdrs, &objp->attrstat_u.attributes)) {
229 return (FALSE);
230 }
231 break;
232 }
233 return (TRUE);
234}
235
236
237
238
239bool_t
240xdr_sattrargs(xdrs, objp)
241 XDR *xdrs;
242 sattrargs *objp;
243{
244 if (!xdr_nfs_fh(xdrs, &objp->file)) {
245 return (FALSE);
246 }
247 if (!xdr_sattr(xdrs, &objp->attributes)) {
248 return (FALSE);
249 }
250 return (TRUE);
251}
252
253
254
255
256bool_t
257xdr_diropargs(xdrs, objp)
258 XDR *xdrs;
259 diropargs *objp;
260{
261 if (!xdr_nfs_fh(xdrs, &objp->dir)) {
262 return (FALSE);
263 }
264 if (!xdr_filename(xdrs, &objp->name)) {
265 return (FALSE);
266 }
267 return (TRUE);
268}
269
270
271
272
273bool_t
274xdr_diropokres(xdrs, objp)
275 XDR *xdrs;
276 diropokres *objp;
277{
278 if (!xdr_nfs_fh(xdrs, &objp->file)) {
279 return (FALSE);
280 }
281 if (!xdr_fattr(xdrs, &objp->attributes)) {
282 return (FALSE);
283 }
284 return (TRUE);
285}
286
287
288
289
290bool_t
291xdr_diropres(xdrs, objp)
292 XDR *xdrs;
293 diropres *objp;
294{
295 if (!xdr_nfsstat(xdrs, &objp->status)) {
296 return (FALSE);
297 }
298 switch (objp->status) {
299 case NFS_OK:
300 if (!xdr_diropokres(xdrs, &objp->diropres_u.diropres)) {
301 return (FALSE);
302 }
303 break;
304 }
305 return (TRUE);
306}
307
308
309
310
311bool_t
312xdr_readlinkres(xdrs, objp)
313 XDR *xdrs;
314 readlinkres *objp;
315{
316 if (!xdr_nfsstat(xdrs, &objp->status)) {
317 return (FALSE);
318 }
319 switch (objp->status) {
320 case NFS_OK:
321 if (!xdr_nfspath(xdrs, &objp->readlinkres_u.data)) {
322 return (FALSE);
323 }
324 break;
325 }
326 return (TRUE);
327}
328
329
330
331
332bool_t
333xdr_readargs(xdrs, objp)
334 XDR *xdrs;
335 readargs *objp;
336{
337 if (!xdr_nfs_fh(xdrs, &objp->file)) {
338 return (FALSE);
339 }
340 if (!xdr_u_int(xdrs, &objp->offset)) {
341 return (FALSE);
342 }
343 if (!xdr_u_int(xdrs, &objp->count)) {
344 return (FALSE);
345 }
346 if (!xdr_u_int(xdrs, &objp->totalcount)) {
347 return (FALSE);
348 }
349 return (TRUE);
350}
351
352
353
354
355bool_t
356xdr_readokres(xdrs, objp)
357 XDR *xdrs;
358 readokres *objp;
359{
360 if (!xdr_fattr(xdrs, &objp->attributes)) {
361 return (FALSE);
362 }
363 if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
364 return (FALSE);
365 }
366 return (TRUE);
367}
368
369
370
371
372bool_t
373xdr_readres(xdrs, objp)
374 XDR *xdrs;
375 readres *objp;
376{
377 if (!xdr_nfsstat(xdrs, &objp->status)) {
378 return (FALSE);
379 }
380 switch (objp->status) {
381 case NFS_OK:
382 if (!xdr_readokres(xdrs, &objp->readres_u.reply)) {
383 return (FALSE);
384 }
385 break;
386 }
387 return (TRUE);
388}
389
390
391
392
393bool_t
394xdr_writeargs(xdrs, objp)
395 XDR *xdrs;
396 writeargs *objp;
397{
398 if (!xdr_nfs_fh(xdrs, &objp->file)) {
399 return (FALSE);
400 }
401 if (!xdr_u_int(xdrs, &objp->beginoffset)) {
402 return (FALSE);
403 }
404 if (!xdr_u_int(xdrs, &objp->offset)) {
405 return (FALSE);
406 }
407 if (!xdr_u_int(xdrs, &objp->totalcount)) {
408 return (FALSE);
409 }
410 if (!xdr_bytes(xdrs, (char **)&objp->data.data_val, (u_int *)&objp->data.data_len, NFS_MAXDATA)) {
411 return (FALSE);
412 }
413 return (TRUE);
414}
415
416
417
418
419bool_t
420xdr_createargs(xdrs, objp)
421 XDR *xdrs;
422 createargs *objp;
423{
424 if (!xdr_diropargs(xdrs, &objp->where)) {
425 return (FALSE);
426 }
427 if (!xdr_sattr(xdrs, &objp->attributes)) {
428 return (FALSE);
429 }
430 return (TRUE);
431}
432
433
434
435
436bool_t
437xdr_renameargs(xdrs, objp)
438 XDR *xdrs;
439 renameargs *objp;
440{
441 if (!xdr_diropargs(xdrs, &objp->from)) {
442 return (FALSE);
443 }
444 if (!xdr_diropargs(xdrs, &objp->to)) {
445 return (FALSE);
446 }
447 return (TRUE);
448}
449
450
451
452
453bool_t
454xdr_linkargs(xdrs, objp)
455 XDR *xdrs;
456 linkargs *objp;
457{
458 if (!xdr_nfs_fh(xdrs, &objp->from)) {
459 return (FALSE);
460 }
461 if (!xdr_diropargs(xdrs, &objp->to)) {
462 return (FALSE);
463 }
464 return (TRUE);
465}
466
467
468
469
470bool_t
471xdr_symlinkargs(xdrs, objp)
472 XDR *xdrs;
473 symlinkargs *objp;
474{
475 if (!xdr_diropargs(xdrs, &objp->from)) {
476 return (FALSE);
477 }
478 if (!xdr_nfspath(xdrs, &objp->to)) {
479 return (FALSE);
480 }
481 if (!xdr_sattr(xdrs, &objp->attributes)) {
482 return (FALSE);
483 }
484 return (TRUE);
485}
486
487
488
489
490static bool_t
491xdr_nfscookie(xdrs, objp)
492 XDR *xdrs;
493 nfscookie objp;
494{
495 if (!xdr_opaque(xdrs, objp, NFS_COOKIESIZE)) {
496 return (FALSE);
497 }
498 return (TRUE);
499}
500
501
502
503
504bool_t
505xdr_readdirargs(xdrs, objp)
506 XDR *xdrs;
507 readdirargs *objp;
508{
509 if (!xdr_nfs_fh(xdrs, &objp->dir)) {
510 return (FALSE);
511 }
512 if (!xdr_nfscookie(xdrs, objp->cookie)) {
513 return (FALSE);
514 }
515 if (!xdr_u_int(xdrs, &objp->count)) {
516 return (FALSE);
517 }
518 return (TRUE);
519}
520
521
522
523
524static bool_t
525xdr_entry(xdrs, objp)
526 XDR *xdrs;
527 entry *objp;
528{
529 if (!xdr_u_int(xdrs, &objp->fileid)) {
530 return (FALSE);
531 }
532 if (!xdr_filename(xdrs, &objp->name)) {
533 return (FALSE);
534 }
535 if (!xdr_nfscookie(xdrs, objp->cookie)) {
536 return (FALSE);
537 }
538 if (!xdr_pointer(xdrs, (char **)&objp->nextentry, sizeof(entry), xdr_entry)) {
539 return (FALSE);
540 }
541 return (TRUE);
542}
543
544
545
546
547static bool_t
548xdr_dirlist(xdrs, objp)
549 XDR *xdrs;
550 dirlist *objp;
551{
552 if (!xdr_pointer(xdrs, (char **)&objp->entries, sizeof(entry), xdr_entry)) {
553 return (FALSE);
554 }
555 if (!xdr_bool(xdrs, &objp->eof)) {
556 return (FALSE);
557 }
558 return (TRUE);
559}
560
561
562
563
564bool_t
565xdr_readdirres(xdrs, objp)
566 XDR *xdrs;
567 readdirres *objp;
568{
569 if (!xdr_nfsstat(xdrs, &objp->status)) {
570 return (FALSE);
571 }
572 switch (objp->status) {
573 case NFS_OK:
574 if (!xdr_dirlist(xdrs, &objp->readdirres_u.reply)) {
575 return (FALSE);
576 }
577 break;
578 }
579 return (TRUE);
580}
581
582
583
584
585bool_t
586xdr_statfsokres(xdrs, objp)
587 XDR *xdrs;
588 statfsokres *objp;
589{
590 if (!xdr_u_int(xdrs, &objp->tsize)) {
591 return (FALSE);
592 }
593 if (!xdr_u_int(xdrs, &objp->bsize)) {
594 return (FALSE);
595 }
596 if (!xdr_u_int(xdrs, &objp->blocks)) {
597 return (FALSE);
598 }
599 if (!xdr_u_int(xdrs, &objp->bfree)) {
600 return (FALSE);
601 }
602 if (!xdr_u_int(xdrs, &objp->bavail)) {
603 return (FALSE);
604 }
605 return (TRUE);
606}
607
608
609
610
611bool_t
612xdr_statfsres(xdrs, objp)
613 XDR *xdrs;
614 statfsres *objp;
615{
616 if (!xdr_nfsstat(xdrs, &objp->status)) {
617 return (FALSE);
618 }
619 switch (objp->status) {
620 case NFS_OK:
621 if (!xdr_statfsokres(xdrs, &objp->statfsres_u.reply)) {
622 return (FALSE);
623 }
624 break;
625 }
626 return (TRUE);
627}