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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2017 Joyent Inc
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/cmn_err.h>
#include <sys/kmem.h>
#include <sys/cred.h>
#include <sys/dirent.h>
#include <sys/debug.h>
#include <rpc/types.h>
#include <nfs/nfs.h>
#include <nfs/export.h>
#include <rpc/svc.h>
#include <rpc/xdr.h>
#include <rpc/rpcb_prot.h>
#include <rpc/clnt.h>
#include <nfs/nfs_log.h>
/*
* nfsl_principal_name_get - extracts principal from transport struct.
* Based on "uts/common/rpc/sec/sec_svc.c" function sec_svc_getcred.
*/
static char *
nfsl_principal_name_get(struct svc_req *req)
{
char *principal_name = NULL;
struct authdes_cred *adc;
rpc_gss_rawcred_t *rcred;
rpc_gss_ucred_t *ucred;
void *cookie;
switch (req->rq_cred.oa_flavor) {
case AUTH_UNIX:
case AUTH_NONE:
/* no principal name provided */
break;
case AUTH_DES:
adc = (struct authdes_cred *)req->rq_clntcred;
CTASSERT(sizeof (struct authdes_cred) <= RQCRED_SIZE);
principal_name = adc->adc_fullname.name;
break;
case RPCSEC_GSS:
(void) rpc_gss_getcred(req, &rcred, &ucred, &cookie);
principal_name = (caddr_t)rcred->client_principal;
break;
default:
break;
}
return (principal_name);
}
bool_t
xdr_timestruc32_t(XDR *xdrs, timestruc32_t *objp)
{
if (!xdr_int(xdrs, &objp->tv_sec))
return (FALSE);
return (xdr_int(xdrs, &objp->tv_nsec));
}
bool_t
xdr_nfsstat(XDR *xdrs, nfsstat *objp)
{
return (xdr_enum(xdrs, (enum_t *)objp));
}
bool_t
xdr_nfslog_sharefsres(XDR *xdrs, nfslog_sharefsres *objp)
{
return (xdr_nfsstat(xdrs, objp));
}
bool_t
xdr_nfsreadargs(XDR *xdrs, struct nfsreadargs *ra)
{
if (xdr_fhandle(xdrs, &ra->ra_fhandle) &&
xdr_u_int(xdrs, &ra->ra_offset) &&
xdr_u_int(xdrs, &ra->ra_count) &&
xdr_u_int(xdrs, &ra->ra_totcount)) {
return (TRUE);
}
return (FALSE);
}
bool_t
xdr_nfslog_nfsreadargs(xdrs, objp)
register XDR *xdrs;
nfslog_nfsreadargs *objp;
{
return (xdr_nfsreadargs(xdrs, objp));
}
/*
* Current version (2 and up) xdr function for buffer header
* uses 64-bit offset (relocated to an 8 byte boundary), version 1 uses 32.
*/
bool_t
xdr_nfslog_buffer_header(xdrs, objp)
register XDR *xdrs;
nfslog_buffer_header *objp;
{
if (!xdr_u_int(xdrs, &objp->bh_length))
return (FALSE);
if (!xdr_rpcvers(xdrs, &objp->bh_version))
return (FALSE);
ASSERT(objp->bh_version > 1);
if (!xdr_u_longlong_t(xdrs, &objp->bh_offset))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->bh_flags))
return (FALSE);
return (xdr_timestruc32_t(xdrs, &objp->bh_timestamp));
}
/*
* Hand coded xdr functions for the kernel ENCODE path
*/
bool_t
xdr_nfslog_request_record(
XDR *xdrs,
struct exportinfo *exi,
struct svc_req *req,
cred_t *cr,
struct netbuf *pnb,
unsigned int reclen,
unsigned int record_id)
{
char *netid = NULL;
char *prin = NULL;
unsigned int flavor;
timestruc32_t ts;
timestruc_t now;
uid_t ruid;
gid_t rgid;
if (xdrs->x_op != XDR_ENCODE)
return (FALSE);
/*
* First we do the encoding of the record header
*/
if (!xdr_u_int(xdrs, &reclen))
return (FALSE);
if (!xdr_u_int(xdrs, &record_id))
return (FALSE);
if (!xdr_rpcprog(xdrs, &req->rq_prog))
return (FALSE);
if (!xdr_rpcproc(xdrs, &req->rq_proc))
return (FALSE);
if (!xdr_rpcvers(xdrs, &req->rq_vers))
return (FALSE);
flavor = req->rq_cred.oa_flavor;
if (!xdr_u_int(xdrs, &flavor))
return (FALSE);
gethrestime(&now);
TIMESPEC_TO_TIMESPEC32(&ts, &now);
if (!xdr_timestruc32_t(xdrs, &ts))
return (FALSE);
/* This code depends on us doing XDR_ENCODE ops only */
ruid = crgetruid(cr);
if (!xdr_uid_t(xdrs, &ruid))
return (FALSE);
rgid = crgetrgid(cr);
if (!xdr_gid_t(xdrs, &rgid))
return (FALSE);
/*
* Now encode the rest of the request record (but not args/res)
*/
prin = nfsl_principal_name_get(req);
if (!xdr_string(xdrs, &prin, ~0))
return (FALSE);
if (req->rq_xprt)
netid = svc_getnetid(req->rq_xprt);
if (!xdr_string(xdrs, &netid, ~0))
return (FALSE);
if (!xdr_string(xdrs, &exi->exi_export.ex_tag, ~0))
return (FALSE);
return (xdr_netbuf(xdrs, pnb));
}
bool_t
xdr_nfslog_sharefsargs(XDR *xdrs, struct exportinfo *objp)
{
if (xdrs->x_op != XDR_ENCODE)
return (FALSE);
if (!xdr_int(xdrs, &objp->exi_export.ex_flags))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->exi_export.ex_anon))
return (FALSE);
if (!xdr_string(xdrs, &objp->exi_export.ex_path, ~0))
return (FALSE);
return (xdr_fhandle(xdrs, &objp->exi_fh));
}
bool_t
xdr_nfslog_getfhargs(XDR *xdrs, nfslog_getfhargs *objp)
{
if (!xdr_fhandle(xdrs, &objp->gfh_fh_buf))
return (FALSE);
return (xdr_string(xdrs, &objp->gfh_path, ~0));
}
bool_t
xdr_nfslog_drok(XDR *xdrs, struct nfsdrok *objp)
{
return (xdr_fhandle(xdrs, &objp->drok_fhandle));
}
bool_t
xdr_nfslog_diropres(XDR *xdrs, struct nfsdiropres *objp)
{
if (!xdr_nfsstat(xdrs, &objp->dr_status))
return (FALSE);
switch (objp->dr_status) {
case NFS_OK:
if (!xdr_nfslog_drok(xdrs, &objp->dr_drok))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_getattrres(XDR *xdrs, struct nfsattrstat *objp)
{
return (xdr_nfsstat(xdrs, &objp->ns_status));
}
bool_t
xdr_nfslog_rrok(XDR *xdrs, struct nfsrrok *objp)
{
if (!xdr_u_int(xdrs, &objp->rrok_attr.na_size))
return (FALSE);
return (xdr_u_int(xdrs, &objp->rrok_count));
}
bool_t
xdr_nfslog_rdresult(XDR *xdrs, struct nfsrdresult *objp)
{
if (!xdr_nfsstat(xdrs, &objp->rr_status))
return (FALSE);
switch (objp->rr_status) {
case NFS_OK:
if (!xdr_nfslog_rrok(xdrs, &objp->rr_u.rr_ok_u))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_writeargs(XDR *xdrs, struct nfswriteargs *objp)
{
if (!xdr_fhandle(xdrs, &objp->wa_args->otw_wa_fhandle))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->wa_args->otw_wa_begoff))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->wa_args->otw_wa_offset))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->wa_args->otw_wa_totcount))
return (FALSE);
return (xdr_u_int(xdrs, &objp->wa_count));
}
bool_t
xdr_nfslog_writeresult(XDR *xdrs, struct nfsattrstat *objp)
{
if (!xdr_nfsstat(xdrs, &objp->ns_status))
return (FALSE);
switch (objp->ns_status) {
case NFS_OK:
if (!xdr_u_int(xdrs, &objp->ns_u.ns_attr_u.na_size))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_diropargs(XDR *xdrs, struct nfsdiropargs *objp)
{
if (!xdr_fhandle(xdrs, objp->da_fhandle))
return (FALSE);
return (xdr_string(xdrs, &objp->da_name, ~0));
}
bool_t
xdr_nfslog_sattr(XDR *xdrs, struct nfssattr *objp)
{
if (!xdr_u_int(xdrs, &objp->sa_mode))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->sa_uid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->sa_gid))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->sa_size))
return (FALSE);
if (!xdr_nfs2_timeval(xdrs, (nfs2_timeval *)&objp->sa_atime))
return (FALSE);
return (xdr_nfs2_timeval(xdrs, (nfs2_timeval *)&objp->sa_mtime));
}
bool_t
xdr_nfslog_createargs(XDR *xdrs, struct nfscreatargs *objp)
{
if (!xdr_nfslog_sattr(xdrs, objp->ca_sa))
return (FALSE);
return (xdr_nfslog_diropargs(xdrs, &objp->ca_da));
}
bool_t
xdr_nfslog_setattrargs(XDR *xdrs, struct nfssaargs *objp)
{
if (!xdr_fhandle(xdrs, &objp->saa_fh))
return (FALSE);
return (xdr_nfslog_sattr(xdrs, &objp->saa_sa));
}
bool_t
xdr_nfslog_rdlnres(XDR *xdrs, struct nfsrdlnres *objp)
{
caddr_t lnres = NULL;
int count;
if (!xdr_nfsstat(xdrs, &objp->rl_status))
return (FALSE);
switch (objp->rl_status) {
case NFS_OK:
if ((count = objp->rl_u.rl_srok_u.srok_count) != 0) {
/*
* allocate extra element for terminating NULL
*/
lnres = kmem_alloc(count + 1, KM_SLEEP);
bcopy(objp->rl_u.rl_srok_u.srok_data, lnres, count);
lnres[count] = '\0';
}
if (!xdr_string(xdrs, &lnres, ~0)) {
if (lnres != NULL)
kmem_free(lnres, count + 1);
return (FALSE);
}
if (lnres != NULL)
kmem_free(lnres, count + 1);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_rnmargs(XDR *xdrs, struct nfsrnmargs *objp)
{
if (!xdr_nfslog_diropargs(xdrs, &objp->rna_from))
return (FALSE);
return (xdr_nfslog_diropargs(xdrs, &objp->rna_to));
}
bool_t
xdr_nfslog_linkargs(XDR *xdrs, struct nfslinkargs *objp)
{
if (!xdr_fhandle(xdrs, objp->la_from))
return (FALSE);
return (xdr_nfslog_diropargs(xdrs, &objp->la_to));
}
bool_t
xdr_nfslog_symlinkargs(XDR *xdrs, struct nfsslargs *objp)
{
if (!xdr_nfslog_diropargs(xdrs, &objp->sla_from))
return (FALSE);
if (!xdr_string(xdrs, &objp->sla_tnm, ~0))
return (FALSE);
return (xdr_nfslog_sattr(xdrs, objp->sla_sa));
}
bool_t
xdr_nfslog_statfs(XDR *xdrs, struct nfsstatfs *objp)
{
return (xdr_nfsstat(xdrs, &objp->fs_status));
}
bool_t
xdr_nfslog_rddirargs(XDR *xdrs, struct nfsrddirargs *objp)
{
if (!xdr_fhandle(xdrs, &objp->rda_fh))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->rda_offset))
return (FALSE);
return (xdr_u_int(xdrs, &objp->rda_count));
}
bool_t
xdr_nfslog_rdok(XDR *xdrs, struct nfsrdok *objp)
{
if (!xdr_u_int(xdrs, &objp->rdok_offset))
return (FALSE);
if (!xdr_u_int(xdrs, &objp->rdok_size))
return (FALSE);
return (xdr_bool(xdrs, &objp->rdok_eof));
}
bool_t
xdr_nfslog_rddirres(XDR *xdrs, struct nfsrddirres *objp)
{
if (!xdr_nfsstat(xdrs, &objp->rd_status))
return (FALSE);
switch (objp->rd_status) {
case NFS_OK:
if (!xdr_nfslog_rdok(xdrs, &objp->rd_u.rd_rdok_u))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_diropargs3(XDR *xdrs, diropargs3 *objp)
{
char *name;
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->dir))
return (FALSE);
if (objp->name != nfs3nametoolong)
name = objp->name;
else {
/*
* The name is not defined, set it to the
* zero length string.
*/
name = NULL;
}
return (xdr_string(xdrs, &name, ~0));
}
bool_t
xdr_nfslog_LOOKUP3res(XDR *xdrs, LOOKUP3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->res_u.ok.object))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_set_size3(XDR *xdrs, set_size3 *objp)
{
if (!xdr_bool(xdrs, &objp->set_it))
return (FALSE);
switch (objp->set_it) {
case TRUE:
if (!xdr_uint64(xdrs, &objp->size))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_createhow3(XDR *xdrs, createhow3 *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->mode))
return (FALSE);
switch (objp->mode) {
case UNCHECKED:
case GUARDED:
if (!xdr_set_size3(xdrs,
&objp->createhow3_u.obj_attributes.size))
return (FALSE);
break;
case EXCLUSIVE:
break;
default:
return (FALSE);
}
return (TRUE);
}
bool_t
xdr_nfslog_CREATE3args(XDR *xdrs, CREATE3args *objp)
{
if (!xdr_nfslog_diropargs3(xdrs, &objp->where))
return (FALSE);
return (xdr_nfslog_createhow3(xdrs, &objp->how));
}
bool_t
xdr_nfslog_CREATE3resok(XDR *xdrs, CREATE3resok *objp)
{
return (xdr_post_op_fh3(xdrs, &objp->obj));
}
bool_t
xdr_nfslog_CREATE3res(XDR *xdrs, CREATE3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_nfslog_CREATE3resok(xdrs, &objp->res_u.ok))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_GETATTR3res(XDR *xdrs, GETATTR3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_ACCESS3args(XDR *xdrs, ACCESS3args *objp)
{
return (xdr_nfslog_nfs_fh3(xdrs, &objp->object));
}
bool_t
xdr_nfslog_ACCESS3res(XDR *xdrs, ACCESS3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_SETATTR3args(XDR *xdrs, SETATTR3args *objp)
{
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->object))
return (FALSE);
return (xdr_set_size3(xdrs, &objp->new_attributes.size));
}
bool_t
xdr_nfslog_SETATTR3res(XDR *xdrs, SETATTR3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_READLINK3res(XDR *xdrs, READLINK3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_string(xdrs, &objp->res_u.ok.data, ~0))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_READ3args(XDR *xdrs, READ3args *objp)
{
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->file))
return (FALSE);
if (!xdr_uint64(xdrs, &objp->offset))
return (FALSE);
return (xdr_uint32(xdrs, &objp->count));
}
bool_t
xdr_nfslog_READ3resok(XDR *xdrs, READ3resok *objp)
{
if (!xdr_uint64(xdrs, &objp->file_attributes.attr.size))
return (FALSE);
if (!xdr_uint32(xdrs, &objp->count))
return (FALSE);
if (!xdr_bool(xdrs, &objp->eof))
return (FALSE);
return (xdr_u_int(xdrs, &objp->size));
}
bool_t
xdr_nfslog_READ3res(XDR *xdrs, READ3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_nfslog_READ3resok(xdrs, &objp->res_u.ok))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_WRITE3args(XDR *xdrs, WRITE3args *objp)
{
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->file))
return (FALSE);
if (!xdr_uint64(xdrs, &objp->offset))
return (FALSE);
if (!xdr_uint32(xdrs, &objp->count))
return (FALSE);
return (xdr_enum(xdrs, (enum_t *)&objp->stable));
}
bool_t
xdr_nfslog_WRITE3resok(XDR *xdrs, WRITE3resok *objp)
{
if (!xdr_uint64(xdrs, &objp->file_wcc.after.attr.size))
return (FALSE);
if (!xdr_uint32(xdrs, &objp->count))
return (FALSE);
return (xdr_enum(xdrs, (enum_t *)&objp->committed));
}
bool_t
xdr_nfslog_WRITE3res(XDR *xdrs, WRITE3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_nfslog_WRITE3resok(xdrs, &objp->res_u.ok))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_MKDIR3args(XDR *xdrs, MKDIR3args *objp)
{
return (xdr_nfslog_diropargs3(xdrs, &objp->where));
}
bool_t
xdr_nfslog_MKDIR3res(XDR *xdrs, MKDIR3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_post_op_fh3(xdrs, &objp->res_u.ok.obj))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_SYMLINK3args(XDR *xdrs, SYMLINK3args *objp)
{
if (!xdr_nfslog_diropargs3(xdrs, &objp->where))
return (FALSE);
return (xdr_string(xdrs, &objp->symlink.symlink_data, ~0));
}
bool_t
xdr_nfslog_SYMLINK3res(XDR *xdrs, SYMLINK3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_post_op_fh3(xdrs, &objp->res_u.ok.obj))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_MKNOD3args(XDR *xdrs, MKNOD3args *objp)
{
if (!xdr_nfslog_diropargs3(xdrs, &objp->where))
return (FALSE);
return (xdr_enum(xdrs, (enum_t *)&objp->what.type));
}
bool_t
xdr_nfslog_MKNOD3res(XDR *xdrs, MKNOD3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_post_op_fh3(xdrs, &objp->res_u.ok.obj))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_REMOVE3args(XDR *xdrs, REMOVE3args *objp)
{
return (xdr_nfslog_diropargs3(xdrs, &objp->object));
}
bool_t
xdr_nfslog_REMOVE3res(XDR *xdrs, REMOVE3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_RMDIR3args(XDR *xdrs, RMDIR3args *objp)
{
return (xdr_nfslog_diropargs3(xdrs, &objp->object));
}
bool_t
xdr_nfslog_RMDIR3res(XDR *xdrs, RMDIR3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_RENAME3args(XDR *xdrs, RENAME3args *objp)
{
if (!xdr_nfslog_diropargs3(xdrs, &objp->from))
return (FALSE);
return (xdr_nfslog_diropargs3(xdrs, &objp->to));
}
bool_t
xdr_nfslog_RENAME3res(XDR *xdrs, RENAME3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_LINK3args(XDR *xdrs, LINK3args *objp)
{
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->file))
return (FALSE);
return (xdr_nfslog_diropargs3(xdrs, &objp->link));
}
bool_t
xdr_nfslog_LINK3res(XDR *xdrs, LINK3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_READDIR3args(XDR *xdrs, READDIR3args *objp)
{
return (xdr_nfslog_nfs_fh3(xdrs, &objp->dir));
}
bool_t
xdr_nfslog_READDIR3res(XDR *xdrs, READDIR3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_READDIRPLUS3args(XDR *xdrs, READDIRPLUS3args *objp)
{
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->dir))
return (FALSE);
if (!xdr_uint32(xdrs, &objp->dircount))
return (FALSE);
return (xdr_uint32(xdrs, &objp->maxcount));
}
#ifdef nextdp
#undef nextdp
#endif
#define nextdp(dp) ((struct dirent64 *)((char *)(dp) + (dp)->d_reclen))
bool_t
xdr_nfslog_READDIRPLUS3resok(XDR *xdrs, READDIRPLUS3resok *objp)
{
struct dirent64 *dp;
bool_t true = TRUE;
bool_t false = FALSE;
int nents;
char *name;
entryplus3_info *infop;
dp = (struct dirent64 *)objp->reply.entries;
nents = objp->size;
infop = objp->infop;
while (nents > 0) {
if (dp->d_reclen == 0)
return (FALSE);
if (dp->d_ino == 0) {
dp = nextdp(dp);
infop++;
nents--;
continue;
}
name = dp->d_name;
if (!xdr_bool(xdrs, &true) ||
!xdr_post_op_fh3(xdrs, &infop->fh) ||
!xdr_string(xdrs, &name, ~0)) {
return (FALSE);
}
dp = nextdp(dp);
infop++;
nents--;
}
if (!xdr_bool(xdrs, &false))
return (FALSE);
return (xdr_bool(xdrs, &objp->reply.eof));
}
bool_t
xdr_nfslog_READDIRPLUS3res(XDR *xdrs, READDIRPLUS3res *objp)
{
if (!xdr_enum(xdrs, (enum_t *)&objp->status))
return (FALSE);
switch (objp->status) {
case NFS3_OK:
if (!xdr_nfslog_READDIRPLUS3resok(xdrs, &objp->res_u.ok))
return (FALSE);
break;
}
return (TRUE);
}
bool_t
xdr_nfslog_FSSTAT3args(XDR *xdrs, FSSTAT3args *objp)
{
return (xdr_nfslog_nfs_fh3(xdrs, &objp->fsroot));
}
bool_t
xdr_nfslog_FSSTAT3res(XDR *xdrs, FSSTAT3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_FSINFO3args(XDR *xdrs, FSINFO3args *objp)
{
return (xdr_nfslog_nfs_fh3(xdrs, &objp->fsroot));
}
bool_t
xdr_nfslog_FSINFO3res(XDR *xdrs, FSINFO3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_PATHCONF3args(XDR *xdrs, PATHCONF3args *objp)
{
return (xdr_nfslog_nfs_fh3(xdrs, &objp->object));
}
bool_t
xdr_nfslog_PATHCONF3res(XDR *xdrs, PATHCONF3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_COMMIT3args(XDR *xdrs, COMMIT3args *objp)
{
if (!xdr_nfslog_nfs_fh3(xdrs, &objp->file))
return (FALSE);
if (!xdr_uint64(xdrs, &objp->offset))
return (FALSE);
return (xdr_uint32(xdrs, &objp->count));
}
bool_t
xdr_nfslog_COMMIT3res(XDR *xdrs, COMMIT3res *objp)
{
return (xdr_enum(xdrs, (enum_t *)&objp->status));
}
bool_t
xdr_nfslog_nfs_fh3(XDR *xdrs, nfs_fh3 *objp)
{
nfs_fh3 fh;
if (objp->fh3_len > NFS_FHMAXDATA || objp->fh3_xlen > NFS_FHMAXDATA) {
fh = *objp;
fh.fh3_len = NFS_FHMAXDATA;
fh.fh3_xlen = NFS_FHMAXDATA;
fh.fh3_length = NFS3_OLDFHSIZE;
return (xdr_nfs_fh3_server(xdrs, &fh));
}
return (xdr_nfs_fh3_server(xdrs, objp));
}
|