1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */ 29a74af21SBoaz Harrosh /* 39a74af21SBoaz Harrosh * XDR types for NFSv3 in nfsd. 49a74af21SBoaz Harrosh * 59a74af21SBoaz Harrosh * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de> 69a74af21SBoaz Harrosh */ 79a74af21SBoaz Harrosh 89a74af21SBoaz Harrosh #ifndef _LINUX_NFSD_XDR3_H 99a74af21SBoaz Harrosh #define _LINUX_NFSD_XDR3_H 109a74af21SBoaz Harrosh 119a74af21SBoaz Harrosh #include "xdr.h" 129a74af21SBoaz Harrosh 139a74af21SBoaz Harrosh struct nfsd3_sattrargs { 149a74af21SBoaz Harrosh struct svc_fh fh; 159a74af21SBoaz Harrosh struct iattr attrs; 169a74af21SBoaz Harrosh int check_guard; 179a74af21SBoaz Harrosh time_t guardtime; 189a74af21SBoaz Harrosh }; 199a74af21SBoaz Harrosh 209a74af21SBoaz Harrosh struct nfsd3_diropargs { 219a74af21SBoaz Harrosh struct svc_fh fh; 229a74af21SBoaz Harrosh char * name; 239a74af21SBoaz Harrosh unsigned int len; 249a74af21SBoaz Harrosh }; 259a74af21SBoaz Harrosh 269a74af21SBoaz Harrosh struct nfsd3_accessargs { 279a74af21SBoaz Harrosh struct svc_fh fh; 289a74af21SBoaz Harrosh unsigned int access; 299a74af21SBoaz Harrosh }; 309a74af21SBoaz Harrosh 319a74af21SBoaz Harrosh struct nfsd3_readargs { 329a74af21SBoaz Harrosh struct svc_fh fh; 339a74af21SBoaz Harrosh __u64 offset; 349a74af21SBoaz Harrosh __u32 count; 359a74af21SBoaz Harrosh int vlen; 369a74af21SBoaz Harrosh }; 379a74af21SBoaz Harrosh 389a74af21SBoaz Harrosh struct nfsd3_writeargs { 399a74af21SBoaz Harrosh svc_fh fh; 409a74af21SBoaz Harrosh __u64 offset; 419a74af21SBoaz Harrosh __u32 count; 429a74af21SBoaz Harrosh int stable; 439a74af21SBoaz Harrosh __u32 len; 448154ef27SChuck Lever struct kvec first; 459a74af21SBoaz Harrosh }; 469a74af21SBoaz Harrosh 479a74af21SBoaz Harrosh struct nfsd3_createargs { 489a74af21SBoaz Harrosh struct svc_fh fh; 499a74af21SBoaz Harrosh char * name; 509a74af21SBoaz Harrosh unsigned int len; 519a74af21SBoaz Harrosh int createmode; 529a74af21SBoaz Harrosh struct iattr attrs; 539a74af21SBoaz Harrosh __be32 * verf; 549a74af21SBoaz Harrosh }; 559a74af21SBoaz Harrosh 569a74af21SBoaz Harrosh struct nfsd3_mknodargs { 579a74af21SBoaz Harrosh struct svc_fh fh; 589a74af21SBoaz Harrosh char * name; 599a74af21SBoaz Harrosh unsigned int len; 609a74af21SBoaz Harrosh __u32 ftype; 619a74af21SBoaz Harrosh __u32 major, minor; 629a74af21SBoaz Harrosh struct iattr attrs; 639a74af21SBoaz Harrosh }; 649a74af21SBoaz Harrosh 659a74af21SBoaz Harrosh struct nfsd3_renameargs { 669a74af21SBoaz Harrosh struct svc_fh ffh; 679a74af21SBoaz Harrosh char * fname; 689a74af21SBoaz Harrosh unsigned int flen; 699a74af21SBoaz Harrosh struct svc_fh tfh; 709a74af21SBoaz Harrosh char * tname; 719a74af21SBoaz Harrosh unsigned int tlen; 729a74af21SBoaz Harrosh }; 739a74af21SBoaz Harrosh 749a74af21SBoaz Harrosh struct nfsd3_readlinkargs { 759a74af21SBoaz Harrosh struct svc_fh fh; 769a74af21SBoaz Harrosh char * buffer; 779a74af21SBoaz Harrosh }; 789a74af21SBoaz Harrosh 799a74af21SBoaz Harrosh struct nfsd3_linkargs { 809a74af21SBoaz Harrosh struct svc_fh ffh; 819a74af21SBoaz Harrosh struct svc_fh tfh; 829a74af21SBoaz Harrosh char * tname; 839a74af21SBoaz Harrosh unsigned int tlen; 849a74af21SBoaz Harrosh }; 859a74af21SBoaz Harrosh 869a74af21SBoaz Harrosh struct nfsd3_symlinkargs { 879a74af21SBoaz Harrosh struct svc_fh ffh; 889a74af21SBoaz Harrosh char * fname; 899a74af21SBoaz Harrosh unsigned int flen; 909a74af21SBoaz Harrosh char * tname; 919a74af21SBoaz Harrosh unsigned int tlen; 929a74af21SBoaz Harrosh struct iattr attrs; 9338a70315SChuck Lever struct kvec first; 949a74af21SBoaz Harrosh }; 959a74af21SBoaz Harrosh 969a74af21SBoaz Harrosh struct nfsd3_readdirargs { 979a74af21SBoaz Harrosh struct svc_fh fh; 989a74af21SBoaz Harrosh __u64 cookie; 999a74af21SBoaz Harrosh __u32 dircount; 1009a74af21SBoaz Harrosh __u32 count; 1019a74af21SBoaz Harrosh __be32 * verf; 1029a74af21SBoaz Harrosh __be32 * buffer; 1039a74af21SBoaz Harrosh }; 1049a74af21SBoaz Harrosh 1059a74af21SBoaz Harrosh struct nfsd3_commitargs { 1069a74af21SBoaz Harrosh struct svc_fh fh; 1079a74af21SBoaz Harrosh __u64 offset; 1089a74af21SBoaz Harrosh __u32 count; 1099a74af21SBoaz Harrosh }; 1109a74af21SBoaz Harrosh 1119a74af21SBoaz Harrosh struct nfsd3_getaclargs { 1129a74af21SBoaz Harrosh struct svc_fh fh; 1139a74af21SBoaz Harrosh int mask; 1149a74af21SBoaz Harrosh }; 1159a74af21SBoaz Harrosh 1169a74af21SBoaz Harrosh struct posix_acl; 1179a74af21SBoaz Harrosh struct nfsd3_setaclargs { 1189a74af21SBoaz Harrosh struct svc_fh fh; 1199a74af21SBoaz Harrosh int mask; 1209a74af21SBoaz Harrosh struct posix_acl *acl_access; 1219a74af21SBoaz Harrosh struct posix_acl *acl_default; 1229a74af21SBoaz Harrosh }; 1239a74af21SBoaz Harrosh 1249a74af21SBoaz Harrosh struct nfsd3_attrstat { 1259a74af21SBoaz Harrosh __be32 status; 1269a74af21SBoaz Harrosh struct svc_fh fh; 1279a74af21SBoaz Harrosh struct kstat stat; 1289a74af21SBoaz Harrosh }; 1299a74af21SBoaz Harrosh 1309a74af21SBoaz Harrosh /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ 1319a74af21SBoaz Harrosh struct nfsd3_diropres { 1329a74af21SBoaz Harrosh __be32 status; 1339a74af21SBoaz Harrosh struct svc_fh dirfh; 1349a74af21SBoaz Harrosh struct svc_fh fh; 1359a74af21SBoaz Harrosh }; 1369a74af21SBoaz Harrosh 1379a74af21SBoaz Harrosh struct nfsd3_accessres { 1389a74af21SBoaz Harrosh __be32 status; 1399a74af21SBoaz Harrosh struct svc_fh fh; 1409a74af21SBoaz Harrosh __u32 access; 1414f4a4fadSJ. Bruce Fields struct kstat stat; 1429a74af21SBoaz Harrosh }; 1439a74af21SBoaz Harrosh 1449a74af21SBoaz Harrosh struct nfsd3_readlinkres { 1459a74af21SBoaz Harrosh __be32 status; 1469a74af21SBoaz Harrosh struct svc_fh fh; 1479a74af21SBoaz Harrosh __u32 len; 1489a74af21SBoaz Harrosh }; 1499a74af21SBoaz Harrosh 1509a74af21SBoaz Harrosh struct nfsd3_readres { 1519a74af21SBoaz Harrosh __be32 status; 1529a74af21SBoaz Harrosh struct svc_fh fh; 1539a74af21SBoaz Harrosh unsigned long count; 1549a74af21SBoaz Harrosh int eof; 1559a74af21SBoaz Harrosh }; 1569a74af21SBoaz Harrosh 1579a74af21SBoaz Harrosh struct nfsd3_writeres { 1589a74af21SBoaz Harrosh __be32 status; 1599a74af21SBoaz Harrosh struct svc_fh fh; 1609a74af21SBoaz Harrosh unsigned long count; 1619a74af21SBoaz Harrosh int committed; 1629a74af21SBoaz Harrosh }; 1639a74af21SBoaz Harrosh 1649a74af21SBoaz Harrosh struct nfsd3_renameres { 1659a74af21SBoaz Harrosh __be32 status; 1669a74af21SBoaz Harrosh struct svc_fh ffh; 1679a74af21SBoaz Harrosh struct svc_fh tfh; 1689a74af21SBoaz Harrosh }; 1699a74af21SBoaz Harrosh 1709a74af21SBoaz Harrosh struct nfsd3_linkres { 1719a74af21SBoaz Harrosh __be32 status; 1729a74af21SBoaz Harrosh struct svc_fh tfh; 1739a74af21SBoaz Harrosh struct svc_fh fh; 1749a74af21SBoaz Harrosh }; 1759a74af21SBoaz Harrosh 1769a74af21SBoaz Harrosh struct nfsd3_readdirres { 1779a74af21SBoaz Harrosh __be32 status; 1789a74af21SBoaz Harrosh struct svc_fh fh; 179068c34c0SJ. Bruce Fields /* Just to save kmalloc on every readdirplus entry (svc_fh is a 180068c34c0SJ. Bruce Fields * little large for the stack): */ 181068c34c0SJ. Bruce Fields struct svc_fh scratch; 1829a74af21SBoaz Harrosh int count; 1839a74af21SBoaz Harrosh __be32 verf[2]; 1849a74af21SBoaz Harrosh 1859a74af21SBoaz Harrosh struct readdir_cd common; 1869a74af21SBoaz Harrosh __be32 * buffer; 1879a74af21SBoaz Harrosh int buflen; 1889a74af21SBoaz Harrosh __be32 * offset; 1899a74af21SBoaz Harrosh __be32 * offset1; 1909a74af21SBoaz Harrosh struct svc_rqst * rqstp; 1919a74af21SBoaz Harrosh 1929a74af21SBoaz Harrosh }; 1939a74af21SBoaz Harrosh 1949a74af21SBoaz Harrosh struct nfsd3_fsstatres { 1959a74af21SBoaz Harrosh __be32 status; 1969a74af21SBoaz Harrosh struct kstatfs stats; 1979a74af21SBoaz Harrosh __u32 invarsec; 1989a74af21SBoaz Harrosh }; 1999a74af21SBoaz Harrosh 2009a74af21SBoaz Harrosh struct nfsd3_fsinfores { 2019a74af21SBoaz Harrosh __be32 status; 2029a74af21SBoaz Harrosh __u32 f_rtmax; 2039a74af21SBoaz Harrosh __u32 f_rtpref; 2049a74af21SBoaz Harrosh __u32 f_rtmult; 2059a74af21SBoaz Harrosh __u32 f_wtmax; 2069a74af21SBoaz Harrosh __u32 f_wtpref; 2079a74af21SBoaz Harrosh __u32 f_wtmult; 2089a74af21SBoaz Harrosh __u32 f_dtpref; 2099a74af21SBoaz Harrosh __u64 f_maxfilesize; 2109a74af21SBoaz Harrosh __u32 f_properties; 2119a74af21SBoaz Harrosh }; 2129a74af21SBoaz Harrosh 2139a74af21SBoaz Harrosh struct nfsd3_pathconfres { 2149a74af21SBoaz Harrosh __be32 status; 2159a74af21SBoaz Harrosh __u32 p_link_max; 2169a74af21SBoaz Harrosh __u32 p_name_max; 2179a74af21SBoaz Harrosh __u32 p_no_trunc; 2189a74af21SBoaz Harrosh __u32 p_chown_restricted; 2199a74af21SBoaz Harrosh __u32 p_case_insensitive; 2209a74af21SBoaz Harrosh __u32 p_case_preserving; 2219a74af21SBoaz Harrosh }; 2229a74af21SBoaz Harrosh 2239a74af21SBoaz Harrosh struct nfsd3_commitres { 2249a74af21SBoaz Harrosh __be32 status; 2259a74af21SBoaz Harrosh struct svc_fh fh; 2269a74af21SBoaz Harrosh }; 2279a74af21SBoaz Harrosh 2289a74af21SBoaz Harrosh struct nfsd3_getaclres { 2299a74af21SBoaz Harrosh __be32 status; 2309a74af21SBoaz Harrosh struct svc_fh fh; 2319a74af21SBoaz Harrosh int mask; 2329a74af21SBoaz Harrosh struct posix_acl *acl_access; 2339a74af21SBoaz Harrosh struct posix_acl *acl_default; 2344f4a4fadSJ. Bruce Fields struct kstat stat; 2359a74af21SBoaz Harrosh }; 2369a74af21SBoaz Harrosh 2379a74af21SBoaz Harrosh /* dummy type for release */ 2389a74af21SBoaz Harrosh struct nfsd3_fhandle_pair { 2399a74af21SBoaz Harrosh __u32 dummy; 2409a74af21SBoaz Harrosh struct svc_fh fh1; 2419a74af21SBoaz Harrosh struct svc_fh fh2; 2429a74af21SBoaz Harrosh }; 2439a74af21SBoaz Harrosh 2449a74af21SBoaz Harrosh /* 2459a74af21SBoaz Harrosh * Storage requirements for XDR arguments and results. 2469a74af21SBoaz Harrosh */ 2479a74af21SBoaz Harrosh union nfsd3_xdrstore { 2489a74af21SBoaz Harrosh struct nfsd3_sattrargs sattrargs; 2499a74af21SBoaz Harrosh struct nfsd3_diropargs diropargs; 2509a74af21SBoaz Harrosh struct nfsd3_readargs readargs; 2519a74af21SBoaz Harrosh struct nfsd3_writeargs writeargs; 2529a74af21SBoaz Harrosh struct nfsd3_createargs createargs; 2539a74af21SBoaz Harrosh struct nfsd3_renameargs renameargs; 2549a74af21SBoaz Harrosh struct nfsd3_linkargs linkargs; 2559a74af21SBoaz Harrosh struct nfsd3_symlinkargs symlinkargs; 2569a74af21SBoaz Harrosh struct nfsd3_readdirargs readdirargs; 2579a74af21SBoaz Harrosh struct nfsd3_diropres diropres; 2589a74af21SBoaz Harrosh struct nfsd3_accessres accessres; 2599a74af21SBoaz Harrosh struct nfsd3_readlinkres readlinkres; 2609a74af21SBoaz Harrosh struct nfsd3_readres readres; 2619a74af21SBoaz Harrosh struct nfsd3_writeres writeres; 2629a74af21SBoaz Harrosh struct nfsd3_renameres renameres; 2639a74af21SBoaz Harrosh struct nfsd3_linkres linkres; 2649a74af21SBoaz Harrosh struct nfsd3_readdirres readdirres; 2659a74af21SBoaz Harrosh struct nfsd3_fsstatres fsstatres; 2669a74af21SBoaz Harrosh struct nfsd3_fsinfores fsinfores; 2679a74af21SBoaz Harrosh struct nfsd3_pathconfres pathconfres; 2689a74af21SBoaz Harrosh struct nfsd3_commitres commitres; 2699a74af21SBoaz Harrosh struct nfsd3_getaclres getaclres; 2709a74af21SBoaz Harrosh }; 2719a74af21SBoaz Harrosh 2729a74af21SBoaz Harrosh #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) 2739a74af21SBoaz Harrosh 274026fec7eSChristoph Hellwig int nfs3svc_decode_fhandle(struct svc_rqst *, __be32 *); 275026fec7eSChristoph Hellwig int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *); 276026fec7eSChristoph Hellwig int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *); 277026fec7eSChristoph Hellwig int nfs3svc_decode_accessargs(struct svc_rqst *, __be32 *); 278026fec7eSChristoph Hellwig int nfs3svc_decode_readargs(struct svc_rqst *, __be32 *); 279026fec7eSChristoph Hellwig int nfs3svc_decode_writeargs(struct svc_rqst *, __be32 *); 280026fec7eSChristoph Hellwig int nfs3svc_decode_createargs(struct svc_rqst *, __be32 *); 281026fec7eSChristoph Hellwig int nfs3svc_decode_mkdirargs(struct svc_rqst *, __be32 *); 282026fec7eSChristoph Hellwig int nfs3svc_decode_mknodargs(struct svc_rqst *, __be32 *); 283026fec7eSChristoph Hellwig int nfs3svc_decode_renameargs(struct svc_rqst *, __be32 *); 284026fec7eSChristoph Hellwig int nfs3svc_decode_readlinkargs(struct svc_rqst *, __be32 *); 285026fec7eSChristoph Hellwig int nfs3svc_decode_linkargs(struct svc_rqst *, __be32 *); 286026fec7eSChristoph Hellwig int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *); 287026fec7eSChristoph Hellwig int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *); 288026fec7eSChristoph Hellwig int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *); 289026fec7eSChristoph Hellwig int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *); 29063f8de37SChristoph Hellwig int nfs3svc_encode_voidres(struct svc_rqst *, __be32 *); 29163f8de37SChristoph Hellwig int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *); 29263f8de37SChristoph Hellwig int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *); 29363f8de37SChristoph Hellwig int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *); 29463f8de37SChristoph Hellwig int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *); 29563f8de37SChristoph Hellwig int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *); 29663f8de37SChristoph Hellwig int nfs3svc_encode_readres(struct svc_rqst *, __be32 *); 29763f8de37SChristoph Hellwig int nfs3svc_encode_writeres(struct svc_rqst *, __be32 *); 29863f8de37SChristoph Hellwig int nfs3svc_encode_createres(struct svc_rqst *, __be32 *); 29963f8de37SChristoph Hellwig int nfs3svc_encode_renameres(struct svc_rqst *, __be32 *); 30063f8de37SChristoph Hellwig int nfs3svc_encode_linkres(struct svc_rqst *, __be32 *); 30163f8de37SChristoph Hellwig int nfs3svc_encode_readdirres(struct svc_rqst *, __be32 *); 30263f8de37SChristoph Hellwig int nfs3svc_encode_fsstatres(struct svc_rqst *, __be32 *); 30363f8de37SChristoph Hellwig int nfs3svc_encode_fsinfores(struct svc_rqst *, __be32 *); 30463f8de37SChristoph Hellwig int nfs3svc_encode_pathconfres(struct svc_rqst *, __be32 *); 30563f8de37SChristoph Hellwig int nfs3svc_encode_commitres(struct svc_rqst *, __be32 *); 3069a74af21SBoaz Harrosh 3078537488bSChristoph Hellwig void nfs3svc_release_fhandle(struct svc_rqst *); 3088537488bSChristoph Hellwig void nfs3svc_release_fhandle2(struct svc_rqst *); 3099a74af21SBoaz Harrosh int nfs3svc_encode_entry(void *, const char *name, 3109a74af21SBoaz Harrosh int namlen, loff_t offset, u64 ino, 3119a74af21SBoaz Harrosh unsigned int); 3129a74af21SBoaz Harrosh int nfs3svc_encode_entry_plus(void *, const char *name, 3139a74af21SBoaz Harrosh int namlen, loff_t offset, u64 ino, 3149a74af21SBoaz Harrosh unsigned int); 3159a74af21SBoaz Harrosh /* Helper functions for NFSv3 ACL code */ 3169a74af21SBoaz Harrosh __be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, 3179a74af21SBoaz Harrosh struct svc_fh *fhp); 3189a74af21SBoaz Harrosh __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp); 3199a74af21SBoaz Harrosh 3209a74af21SBoaz Harrosh 3219a74af21SBoaz Harrosh #endif /* _LINUX_NFSD_XDR3_H */ 322