1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* 3 * XDR types for NFSv3 in nfsd. 4 * 5 * Copyright (C) 1996-1998, Olaf Kirch <okir@monad.swb.de> 6 */ 7 8 #ifndef _LINUX_NFSD_XDR3_H 9 #define _LINUX_NFSD_XDR3_H 10 11 #include "xdr.h" 12 #include "vfs.h" 13 14 struct nfsd3_sattrargs { 15 struct svc_fh fh; 16 struct iattr attrs; 17 int check_guard; 18 struct timespec64 guardtime; 19 }; 20 21 struct nfsd3_diropargs { 22 struct svc_fh fh; 23 char * name; 24 unsigned int len; 25 }; 26 27 struct nfsd3_accessargs { 28 struct svc_fh fh; 29 __u32 access; 30 }; 31 32 struct nfsd3_readargs { 33 struct svc_fh fh; 34 __u64 offset; 35 __u32 count; 36 }; 37 38 struct nfsd3_writeargs { 39 svc_fh fh; 40 __u64 offset; 41 __u32 count; 42 int stable; 43 __u32 len; 44 struct xdr_buf payload; 45 }; 46 47 struct nfsd3_createargs { 48 struct svc_fh fh; 49 char * name; 50 unsigned int len; 51 int createmode; 52 struct iattr attrs; 53 __be32 * verf; 54 }; 55 56 struct nfsd3_mknodargs { 57 struct svc_fh fh; 58 char * name; 59 unsigned int len; 60 __u32 ftype; 61 __u32 major, minor; 62 struct iattr attrs; 63 }; 64 65 struct nfsd3_renameargs { 66 struct svc_fh ffh; 67 char * fname; 68 unsigned int flen; 69 struct svc_fh tfh; 70 char * tname; 71 unsigned int tlen; 72 }; 73 74 struct nfsd3_linkargs { 75 struct svc_fh ffh; 76 struct svc_fh tfh; 77 char * tname; 78 unsigned int tlen; 79 }; 80 81 struct nfsd3_symlinkargs { 82 struct svc_fh ffh; 83 char * fname; 84 unsigned int flen; 85 char * tname; 86 unsigned int tlen; 87 struct iattr attrs; 88 struct kvec first; 89 }; 90 91 struct nfsd3_readdirargs { 92 struct svc_fh fh; 93 __u64 cookie; 94 __u32 count; 95 __be32 * verf; 96 }; 97 98 struct nfsd3_commitargs { 99 struct svc_fh fh; 100 __u64 offset; 101 __u32 count; 102 }; 103 104 struct nfsd3_getaclargs { 105 struct svc_fh fh; 106 __u32 mask; 107 }; 108 109 struct posix_acl; 110 struct nfsd3_setaclargs { 111 struct svc_fh fh; 112 __u32 mask; 113 struct posix_acl *acl_access; 114 struct posix_acl *acl_default; 115 }; 116 117 struct nfsd3_attrstat { 118 __be32 status; 119 struct svc_fh fh; 120 struct kstat stat; 121 }; 122 123 /* LOOKUP, CREATE, MKDIR, SYMLINK, MKNOD */ 124 struct nfsd3_diropres { 125 __be32 status; 126 struct svc_fh dirfh; 127 struct svc_fh fh; 128 }; 129 130 struct nfsd3_accessres { 131 __be32 status; 132 struct svc_fh fh; 133 __u32 access; 134 struct kstat stat; 135 }; 136 137 struct nfsd3_readlinkres { 138 __be32 status; 139 struct svc_fh fh; 140 __u32 len; 141 struct page **pages; 142 }; 143 144 struct nfsd3_readres { 145 __be32 status; 146 struct svc_fh fh; 147 unsigned long count; 148 __u32 eof; 149 struct page **pages; 150 }; 151 152 struct nfsd3_writeres { 153 __be32 status; 154 struct svc_fh fh; 155 unsigned long count; 156 int committed; 157 __be32 verf[2]; 158 }; 159 160 struct nfsd3_renameres { 161 __be32 status; 162 struct svc_fh ffh; 163 struct svc_fh tfh; 164 }; 165 166 struct nfsd3_linkres { 167 __be32 status; 168 struct svc_fh tfh; 169 struct svc_fh fh; 170 }; 171 172 struct nfsd3_readdirres { 173 /* Components of the reply */ 174 __be32 status; 175 struct svc_fh fh; 176 __be32 verf[2]; 177 178 /* Used to encode the reply's entry list */ 179 struct xdr_stream xdr; 180 struct xdr_buf dirlist; 181 struct svc_fh scratch; 182 struct readdir_cd common; 183 unsigned int cookie_offset; 184 struct svc_rqst * rqstp; 185 186 }; 187 188 struct nfsd3_fsstatres { 189 __be32 status; 190 struct kstatfs stats; 191 __u32 invarsec; 192 }; 193 194 struct nfsd3_fsinfores { 195 __be32 status; 196 __u32 f_rtmax; 197 __u32 f_rtpref; 198 __u32 f_rtmult; 199 __u32 f_wtmax; 200 __u32 f_wtpref; 201 __u32 f_wtmult; 202 __u32 f_dtpref; 203 __u64 f_maxfilesize; 204 __u32 f_properties; 205 }; 206 207 struct nfsd3_pathconfres { 208 __be32 status; 209 __u32 p_link_max; 210 __u32 p_name_max; 211 __u32 p_no_trunc; 212 __u32 p_chown_restricted; 213 bool p_case_insensitive; 214 bool p_case_preserving; 215 }; 216 217 struct nfsd3_commitres { 218 __be32 status; 219 struct svc_fh fh; 220 __be32 verf[2]; 221 }; 222 223 struct nfsd3_getaclres { 224 __be32 status; 225 struct svc_fh fh; 226 int mask; 227 struct posix_acl *acl_access; 228 struct posix_acl *acl_default; 229 struct kstat stat; 230 }; 231 232 /* dummy type for release */ 233 struct nfsd3_fhandle_pair { 234 __u32 dummy; 235 struct svc_fh fh1; 236 struct svc_fh fh2; 237 }; 238 239 /* 240 * Storage requirements for XDR arguments and results. 241 */ 242 union nfsd3_xdrstore { 243 struct nfsd3_sattrargs sattrargs; 244 struct nfsd3_diropargs diropargs; 245 struct nfsd3_readargs readargs; 246 struct nfsd3_writeargs writeargs; 247 struct nfsd3_createargs createargs; 248 struct nfsd3_renameargs renameargs; 249 struct nfsd3_linkargs linkargs; 250 struct nfsd3_symlinkargs symlinkargs; 251 struct nfsd3_readdirargs readdirargs; 252 struct nfsd3_diropres diropres; 253 struct nfsd3_accessres accessres; 254 struct nfsd3_readlinkres readlinkres; 255 struct nfsd3_readres readres; 256 struct nfsd3_writeres writeres; 257 struct nfsd3_renameres renameres; 258 struct nfsd3_linkres linkres; 259 struct nfsd3_readdirres readdirres; 260 struct nfsd3_fsstatres fsstatres; 261 struct nfsd3_fsinfores fsinfores; 262 struct nfsd3_pathconfres pathconfres; 263 struct nfsd3_commitres commitres; 264 struct nfsd3_getaclres getaclres; 265 }; 266 267 #define NFS3_SVC_XDRSIZE sizeof(union nfsd3_xdrstore) 268 269 bool nfs3svc_decode_fhandleargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 270 bool nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 271 bool nfs3svc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 272 bool nfs3svc_decode_accessargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 273 bool nfs3svc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 274 bool nfs3svc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 275 bool nfs3svc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 276 bool nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 277 bool nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 278 bool nfs3svc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 279 bool nfs3svc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 280 bool nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 281 bool nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 282 bool nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 283 bool nfs3svc_decode_commitargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 284 285 bool nfs3svc_encode_getattrres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 286 bool nfs3svc_encode_wccstat(struct svc_rqst *rqstp, struct xdr_stream *xdr); 287 bool nfs3svc_encode_lookupres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 288 bool nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 289 bool nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 290 bool nfs3svc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 291 bool nfs3svc_encode_writeres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 292 bool nfs3svc_encode_createres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 293 bool nfs3svc_encode_renameres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 294 bool nfs3svc_encode_linkres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 295 bool nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 296 bool nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 297 bool nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr); 298 bool nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 299 bool nfs3svc_encode_commitres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 300 301 void nfs3svc_release_fhandle(struct svc_rqst *); 302 void nfs3svc_release_fhandle2(struct svc_rqst *); 303 304 void nfs3svc_encode_cookie3(struct nfsd3_readdirres *resp, u64 offset); 305 int nfs3svc_encode_entry3(void *data, const char *name, int namlen, 306 loff_t offset, u64 ino, unsigned int d_type); 307 int nfs3svc_encode_entryplus3(void *data, const char *name, int namlen, 308 loff_t offset, u64 ino, unsigned int d_type); 309 /* Helper functions for NFSv3 ACL code */ 310 bool svcxdr_decode_nfs_fh3(struct xdr_stream *xdr, struct svc_fh *fhp); 311 bool svcxdr_encode_nfsstat3(struct xdr_stream *xdr, __be32 status); 312 bool svcxdr_encode_post_op_attr(struct svc_rqst *rqstp, struct xdr_stream *xdr, 313 const struct svc_fh *fhp); 314 315 #endif /* _LINUX_NFSD_XDR3_H */ 316