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; 172a1aa489SArnd Bergmann time64_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; 283b921a2bSChuck Lever __u32 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 }; 369a74af21SBoaz Harrosh 379a74af21SBoaz Harrosh struct nfsd3_writeargs { 389a74af21SBoaz Harrosh svc_fh fh; 399a74af21SBoaz Harrosh __u64 offset; 409a74af21SBoaz Harrosh __u32 count; 419a74af21SBoaz Harrosh int stable; 429a74af21SBoaz Harrosh __u32 len; 438154ef27SChuck Lever struct kvec first; 449a74af21SBoaz Harrosh }; 459a74af21SBoaz Harrosh 469a74af21SBoaz Harrosh struct nfsd3_createargs { 479a74af21SBoaz Harrosh struct svc_fh fh; 489a74af21SBoaz Harrosh char * name; 499a74af21SBoaz Harrosh unsigned int len; 509a74af21SBoaz Harrosh int createmode; 519a74af21SBoaz Harrosh struct iattr attrs; 529a74af21SBoaz Harrosh __be32 * verf; 539a74af21SBoaz Harrosh }; 549a74af21SBoaz Harrosh 559a74af21SBoaz Harrosh struct nfsd3_mknodargs { 569a74af21SBoaz Harrosh struct svc_fh fh; 579a74af21SBoaz Harrosh char * name; 589a74af21SBoaz Harrosh unsigned int len; 599a74af21SBoaz Harrosh __u32 ftype; 609a74af21SBoaz Harrosh __u32 major, minor; 619a74af21SBoaz Harrosh struct iattr attrs; 629a74af21SBoaz Harrosh }; 639a74af21SBoaz Harrosh 649a74af21SBoaz Harrosh struct nfsd3_renameargs { 659a74af21SBoaz Harrosh struct svc_fh ffh; 669a74af21SBoaz Harrosh char * fname; 679a74af21SBoaz Harrosh unsigned int flen; 689a74af21SBoaz Harrosh struct svc_fh tfh; 699a74af21SBoaz Harrosh char * tname; 709a74af21SBoaz Harrosh unsigned int tlen; 719a74af21SBoaz Harrosh }; 729a74af21SBoaz Harrosh 739a74af21SBoaz Harrosh struct nfsd3_linkargs { 749a74af21SBoaz Harrosh struct svc_fh ffh; 759a74af21SBoaz Harrosh struct svc_fh tfh; 769a74af21SBoaz Harrosh char * tname; 779a74af21SBoaz Harrosh unsigned int tlen; 789a74af21SBoaz Harrosh }; 799a74af21SBoaz Harrosh 809a74af21SBoaz Harrosh struct nfsd3_symlinkargs { 819a74af21SBoaz Harrosh struct svc_fh ffh; 829a74af21SBoaz Harrosh char * fname; 839a74af21SBoaz Harrosh unsigned int flen; 849a74af21SBoaz Harrosh char * tname; 859a74af21SBoaz Harrosh unsigned int tlen; 869a74af21SBoaz Harrosh struct iattr attrs; 8738a70315SChuck Lever struct kvec first; 889a74af21SBoaz Harrosh }; 899a74af21SBoaz Harrosh 909a74af21SBoaz Harrosh struct nfsd3_readdirargs { 919a74af21SBoaz Harrosh struct svc_fh fh; 929a74af21SBoaz Harrosh __u64 cookie; 939a74af21SBoaz Harrosh __u32 count; 949a74af21SBoaz Harrosh __be32 * verf; 959a74af21SBoaz Harrosh }; 969a74af21SBoaz Harrosh 979a74af21SBoaz Harrosh struct nfsd3_commitargs { 989a74af21SBoaz Harrosh struct svc_fh fh; 999a74af21SBoaz Harrosh __u64 offset; 1009a74af21SBoaz Harrosh __u32 count; 1019a74af21SBoaz Harrosh }; 1029a74af21SBoaz Harrosh 1039a74af21SBoaz Harrosh struct nfsd3_getaclargs { 1049a74af21SBoaz Harrosh struct svc_fh fh; 105635a45d3SChuck Lever __u32 mask; 1069a74af21SBoaz Harrosh }; 1079a74af21SBoaz Harrosh 1089a74af21SBoaz Harrosh struct posix_acl; 1099a74af21SBoaz Harrosh struct nfsd3_setaclargs { 1109a74af21SBoaz Harrosh struct svc_fh fh; 111*427eab3bSChuck Lever __u32 mask; 1129a74af21SBoaz Harrosh struct posix_acl *acl_access; 1139a74af21SBoaz Harrosh struct posix_acl *acl_default; 1149a74af21SBoaz Harrosh }; 1159a74af21SBoaz Harrosh 1169a74af21SBoaz Harrosh struct nfsd3_attrstat { 1179a74af21SBoaz Harrosh __be32 status; 1189a74af21SBoaz Harrosh struct svc_fh fh; 1199a74af21SBoaz Harrosh struct kstat stat; 1209a74af21SBoaz Harrosh }; 1219a74af21SBoaz Harrosh 1229a74af21SBoaz Harrosh /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ 1239a74af21SBoaz Harrosh struct nfsd3_diropres { 1249a74af21SBoaz Harrosh __be32 status; 1259a74af21SBoaz Harrosh struct svc_fh dirfh; 1269a74af21SBoaz Harrosh struct svc_fh fh; 1279a74af21SBoaz Harrosh }; 1289a74af21SBoaz Harrosh 1299a74af21SBoaz Harrosh struct nfsd3_accessres { 1309a74af21SBoaz Harrosh __be32 status; 1319a74af21SBoaz Harrosh struct svc_fh fh; 1329a74af21SBoaz Harrosh __u32 access; 1334f4a4fadSJ. Bruce Fields struct kstat stat; 1349a74af21SBoaz Harrosh }; 1359a74af21SBoaz Harrosh 1369a74af21SBoaz Harrosh struct nfsd3_readlinkres { 1379a74af21SBoaz Harrosh __be32 status; 1389a74af21SBoaz Harrosh struct svc_fh fh; 1399a74af21SBoaz Harrosh __u32 len; 1409a74af21SBoaz Harrosh }; 1419a74af21SBoaz Harrosh 1429a74af21SBoaz Harrosh struct nfsd3_readres { 1439a74af21SBoaz Harrosh __be32 status; 1449a74af21SBoaz Harrosh struct svc_fh fh; 1459a74af21SBoaz Harrosh unsigned long count; 14683a63072STrond Myklebust __u32 eof; 1479a74af21SBoaz Harrosh }; 1489a74af21SBoaz Harrosh 1499a74af21SBoaz Harrosh struct nfsd3_writeres { 1509a74af21SBoaz Harrosh __be32 status; 1519a74af21SBoaz Harrosh struct svc_fh fh; 1529a74af21SBoaz Harrosh unsigned long count; 1539a74af21SBoaz Harrosh int committed; 15419e0663fSTrond Myklebust __be32 verf[2]; 1559a74af21SBoaz Harrosh }; 1569a74af21SBoaz Harrosh 1579a74af21SBoaz Harrosh struct nfsd3_renameres { 1589a74af21SBoaz Harrosh __be32 status; 1599a74af21SBoaz Harrosh struct svc_fh ffh; 1609a74af21SBoaz Harrosh struct svc_fh tfh; 1619a74af21SBoaz Harrosh }; 1629a74af21SBoaz Harrosh 1639a74af21SBoaz Harrosh struct nfsd3_linkres { 1649a74af21SBoaz Harrosh __be32 status; 1659a74af21SBoaz Harrosh struct svc_fh tfh; 1669a74af21SBoaz Harrosh struct svc_fh fh; 1679a74af21SBoaz Harrosh }; 1689a74af21SBoaz Harrosh 1699a74af21SBoaz Harrosh struct nfsd3_readdirres { 1709a74af21SBoaz Harrosh __be32 status; 1719a74af21SBoaz Harrosh struct svc_fh fh; 172068c34c0SJ. Bruce Fields /* Just to save kmalloc on every readdirplus entry (svc_fh is a 173068c34c0SJ. Bruce Fields * little large for the stack): */ 174068c34c0SJ. Bruce Fields struct svc_fh scratch; 1759a74af21SBoaz Harrosh int count; 1769a74af21SBoaz Harrosh __be32 verf[2]; 1779a74af21SBoaz Harrosh 1789a74af21SBoaz Harrosh struct readdir_cd common; 1799a74af21SBoaz Harrosh __be32 * buffer; 1809a74af21SBoaz Harrosh int buflen; 1819a74af21SBoaz Harrosh __be32 * offset; 1829a74af21SBoaz Harrosh __be32 * offset1; 1839a74af21SBoaz Harrosh struct svc_rqst * rqstp; 1849a74af21SBoaz Harrosh 1859a74af21SBoaz Harrosh }; 1869a74af21SBoaz Harrosh 1879a74af21SBoaz Harrosh struct nfsd3_fsstatres { 1889a74af21SBoaz Harrosh __be32 status; 1899a74af21SBoaz Harrosh struct kstatfs stats; 1909a74af21SBoaz Harrosh __u32 invarsec; 1919a74af21SBoaz Harrosh }; 1929a74af21SBoaz Harrosh 1939a74af21SBoaz Harrosh struct nfsd3_fsinfores { 1949a74af21SBoaz Harrosh __be32 status; 1959a74af21SBoaz Harrosh __u32 f_rtmax; 1969a74af21SBoaz Harrosh __u32 f_rtpref; 1979a74af21SBoaz Harrosh __u32 f_rtmult; 1989a74af21SBoaz Harrosh __u32 f_wtmax; 1999a74af21SBoaz Harrosh __u32 f_wtpref; 2009a74af21SBoaz Harrosh __u32 f_wtmult; 2019a74af21SBoaz Harrosh __u32 f_dtpref; 2029a74af21SBoaz Harrosh __u64 f_maxfilesize; 2039a74af21SBoaz Harrosh __u32 f_properties; 2049a74af21SBoaz Harrosh }; 2059a74af21SBoaz Harrosh 2069a74af21SBoaz Harrosh struct nfsd3_pathconfres { 2079a74af21SBoaz Harrosh __be32 status; 2089a74af21SBoaz Harrosh __u32 p_link_max; 2099a74af21SBoaz Harrosh __u32 p_name_max; 2109a74af21SBoaz Harrosh __u32 p_no_trunc; 2119a74af21SBoaz Harrosh __u32 p_chown_restricted; 2129a74af21SBoaz Harrosh __u32 p_case_insensitive; 2139a74af21SBoaz Harrosh __u32 p_case_preserving; 2149a74af21SBoaz Harrosh }; 2159a74af21SBoaz Harrosh 2169a74af21SBoaz Harrosh struct nfsd3_commitres { 2179a74af21SBoaz Harrosh __be32 status; 2189a74af21SBoaz Harrosh struct svc_fh fh; 219524ff1afSTrond Myklebust __be32 verf[2]; 2209a74af21SBoaz Harrosh }; 2219a74af21SBoaz Harrosh 2229a74af21SBoaz Harrosh struct nfsd3_getaclres { 2239a74af21SBoaz Harrosh __be32 status; 2249a74af21SBoaz Harrosh struct svc_fh fh; 2259a74af21SBoaz Harrosh int mask; 2269a74af21SBoaz Harrosh struct posix_acl *acl_access; 2279a74af21SBoaz Harrosh struct posix_acl *acl_default; 2284f4a4fadSJ. Bruce Fields struct kstat stat; 2299a74af21SBoaz Harrosh }; 2309a74af21SBoaz Harrosh 2319a74af21SBoaz Harrosh /* dummy type for release */ 2329a74af21SBoaz Harrosh struct nfsd3_fhandle_pair { 2339a74af21SBoaz Harrosh __u32 dummy; 2349a74af21SBoaz Harrosh struct svc_fh fh1; 2359a74af21SBoaz Harrosh struct svc_fh fh2; 2369a74af21SBoaz Harrosh }; 2379a74af21SBoaz Harrosh 2389a74af21SBoaz Harrosh /* 2399a74af21SBoaz Harrosh * Storage requirements for XDR arguments and results. 2409a74af21SBoaz Harrosh */ 2419a74af21SBoaz Harrosh union nfsd3_xdrstore { 2429a74af21SBoaz Harrosh struct nfsd3_sattrargs sattrargs; 2439a74af21SBoaz Harrosh struct nfsd3_diropargs diropargs; 2449a74af21SBoaz Harrosh struct nfsd3_readargs readargs; 2459a74af21SBoaz Harrosh struct nfsd3_writeargs writeargs; 2469a74af21SBoaz Harrosh struct nfsd3_createargs createargs; 2479a74af21SBoaz Harrosh struct nfsd3_renameargs renameargs; 2489a74af21SBoaz Harrosh struct nfsd3_linkargs linkargs; 2499a74af21SBoaz Harrosh struct nfsd3_symlinkargs symlinkargs; 2509a74af21SBoaz Harrosh struct nfsd3_readdirargs readdirargs; 2519a74af21SBoaz Harrosh struct nfsd3_diropres diropres; 2529a74af21SBoaz Harrosh struct nfsd3_accessres accessres; 2539a74af21SBoaz Harrosh struct nfsd3_readlinkres readlinkres; 2549a74af21SBoaz Harrosh struct nfsd3_readres readres; 2559a74af21SBoaz Harrosh struct nfsd3_writeres writeres; 2569a74af21SBoaz Harrosh struct nfsd3_renameres renameres; 2579a74af21SBoaz Harrosh struct nfsd3_linkres linkres; 2589a74af21SBoaz Harrosh struct nfsd3_readdirres readdirres; 2599a74af21SBoaz Harrosh struct nfsd3_fsstatres fsstatres; 2609a74af21SBoaz Harrosh struct nfsd3_fsinfores fsinfores; 2619a74af21SBoaz Harrosh struct nfsd3_pathconfres pathconfres; 2629a74af21SBoaz Harrosh struct nfsd3_commitres commitres; 2639a74af21SBoaz Harrosh struct nfsd3_getaclres getaclres; 2649a74af21SBoaz Harrosh }; 2659a74af21SBoaz Harrosh 2669a74af21SBoaz Harrosh #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) 2679a74af21SBoaz Harrosh 2689575363aSChuck Lever int nfs3svc_decode_fhandleargs(struct svc_rqst *, __be32 *); 269026fec7eSChristoph Hellwig int nfs3svc_decode_sattrargs(struct svc_rqst *, __be32 *); 270026fec7eSChristoph Hellwig int nfs3svc_decode_diropargs(struct svc_rqst *, __be32 *); 271026fec7eSChristoph Hellwig int nfs3svc_decode_accessargs(struct svc_rqst *, __be32 *); 272026fec7eSChristoph Hellwig int nfs3svc_decode_readargs(struct svc_rqst *, __be32 *); 273026fec7eSChristoph Hellwig int nfs3svc_decode_writeargs(struct svc_rqst *, __be32 *); 274026fec7eSChristoph Hellwig int nfs3svc_decode_createargs(struct svc_rqst *, __be32 *); 275026fec7eSChristoph Hellwig int nfs3svc_decode_mkdirargs(struct svc_rqst *, __be32 *); 276026fec7eSChristoph Hellwig int nfs3svc_decode_mknodargs(struct svc_rqst *, __be32 *); 277026fec7eSChristoph Hellwig int nfs3svc_decode_renameargs(struct svc_rqst *, __be32 *); 278026fec7eSChristoph Hellwig int nfs3svc_decode_linkargs(struct svc_rqst *, __be32 *); 279026fec7eSChristoph Hellwig int nfs3svc_decode_symlinkargs(struct svc_rqst *, __be32 *); 280026fec7eSChristoph Hellwig int nfs3svc_decode_readdirargs(struct svc_rqst *, __be32 *); 281026fec7eSChristoph Hellwig int nfs3svc_decode_readdirplusargs(struct svc_rqst *, __be32 *); 282026fec7eSChristoph Hellwig int nfs3svc_decode_commitargs(struct svc_rqst *, __be32 *); 28363f8de37SChristoph Hellwig int nfs3svc_encode_attrstat(struct svc_rqst *, __be32 *); 28463f8de37SChristoph Hellwig int nfs3svc_encode_wccstat(struct svc_rqst *, __be32 *); 28563f8de37SChristoph Hellwig int nfs3svc_encode_diropres(struct svc_rqst *, __be32 *); 28663f8de37SChristoph Hellwig int nfs3svc_encode_accessres(struct svc_rqst *, __be32 *); 28763f8de37SChristoph Hellwig int nfs3svc_encode_readlinkres(struct svc_rqst *, __be32 *); 28863f8de37SChristoph Hellwig int nfs3svc_encode_readres(struct svc_rqst *, __be32 *); 28963f8de37SChristoph Hellwig int nfs3svc_encode_writeres(struct svc_rqst *, __be32 *); 29063f8de37SChristoph Hellwig int nfs3svc_encode_createres(struct svc_rqst *, __be32 *); 29163f8de37SChristoph Hellwig int nfs3svc_encode_renameres(struct svc_rqst *, __be32 *); 29263f8de37SChristoph Hellwig int nfs3svc_encode_linkres(struct svc_rqst *, __be32 *); 29363f8de37SChristoph Hellwig int nfs3svc_encode_readdirres(struct svc_rqst *, __be32 *); 29463f8de37SChristoph Hellwig int nfs3svc_encode_fsstatres(struct svc_rqst *, __be32 *); 29563f8de37SChristoph Hellwig int nfs3svc_encode_fsinfores(struct svc_rqst *, __be32 *); 29663f8de37SChristoph Hellwig int nfs3svc_encode_pathconfres(struct svc_rqst *, __be32 *); 29763f8de37SChristoph Hellwig int nfs3svc_encode_commitres(struct svc_rqst *, __be32 *); 2989a74af21SBoaz Harrosh 2998537488bSChristoph Hellwig void nfs3svc_release_fhandle(struct svc_rqst *); 3008537488bSChristoph Hellwig void nfs3svc_release_fhandle2(struct svc_rqst *); 3019a74af21SBoaz Harrosh int nfs3svc_encode_entry(void *, const char *name, 3029a74af21SBoaz Harrosh int namlen, loff_t offset, u64 ino, 3039a74af21SBoaz Harrosh unsigned int); 3049a74af21SBoaz Harrosh int nfs3svc_encode_entry_plus(void *, const char *name, 3059a74af21SBoaz Harrosh int namlen, loff_t offset, u64 ino, 3069a74af21SBoaz Harrosh unsigned int); 3079a74af21SBoaz Harrosh /* Helper functions for NFSv3 ACL code */ 3089a74af21SBoaz Harrosh __be32 *nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, 3099a74af21SBoaz Harrosh struct svc_fh *fhp); 3109a74af21SBoaz Harrosh __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp); 3119a74af21SBoaz Harrosh 3129a74af21SBoaz Harrosh 3139a74af21SBoaz Harrosh #endif /* _LINUX_NFSD_XDR3_H */ 314