^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/fs/nfs/nfs3xdr.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * XDR functions to encode/decode NFSv3 RPC arguments and results.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * Copyright (C) 1996, 1997 Olaf Kirch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/param.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/time.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/in.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/proc_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/kdev_t.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/sunrpc/clnt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/nfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/nfs3.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/nfs_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/nfsacl.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include "nfstrace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include "internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define NFSDBG_FACILITY NFSDBG_XDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) /* Mapping from NFS error code to "errno" error code. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define errno_NFSERR_IO EIO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * Declare the space requirements for NFS arguments and replies as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * number of 32bit-words
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define NFS3_fhandle_sz (1+16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define NFS3_fh_sz (NFS3_fhandle_sz) /* shorthand */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define NFS3_post_op_fh_sz (1+NFS3_fh_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define NFS3_sattr_sz (15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #define NFS3_fattr_sz (21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define NFS3_cookieverf_sz (NFS3_COOKIEVERFSIZE>>2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define NFS3_wcc_attr_sz (6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #define NFS3_pre_op_attr_sz (1+NFS3_wcc_attr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define NFS3_post_op_attr_sz (1+NFS3_fattr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #define NFS3_wcc_data_sz (NFS3_pre_op_attr_sz+NFS3_post_op_attr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define NFS3_diropargs_sz (NFS3_fh_sz+NFS3_filename_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define NFS3_getattrargs_sz (NFS3_fh_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) #define NFS3_setattrargs_sz (NFS3_fh_sz+NFS3_sattr_sz+3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define NFS3_lookupargs_sz (NFS3_fh_sz+NFS3_filename_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define NFS3_accessargs_sz (NFS3_fh_sz+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define NFS3_readlinkargs_sz (NFS3_fh_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) #define NFS3_readargs_sz (NFS3_fh_sz+3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) #define NFS3_writeargs_sz (NFS3_fh_sz+5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) #define NFS3_createargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define NFS3_mkdirargs_sz (NFS3_diropargs_sz+NFS3_sattr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #define NFS3_symlinkargs_sz (NFS3_diropargs_sz+1+NFS3_sattr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) #define NFS3_mknodargs_sz (NFS3_diropargs_sz+2+NFS3_sattr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #define NFS3_removeargs_sz (NFS3_fh_sz+NFS3_filename_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) #define NFS3_renameargs_sz (NFS3_diropargs_sz+NFS3_diropargs_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) #define NFS3_linkargs_sz (NFS3_fh_sz+NFS3_diropargs_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define NFS3_readdirargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define NFS3_readdirplusargs_sz (NFS3_fh_sz+NFS3_cookieverf_sz+4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define NFS3_commitargs_sz (NFS3_fh_sz+3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define NFS3_getattrres_sz (1+NFS3_fattr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define NFS3_setattrres_sz (1+NFS3_wcc_data_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define NFS3_removeres_sz (NFS3_setattrres_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define NFS3_lookupres_sz (1+NFS3_fh_sz+(2 * NFS3_post_op_attr_sz))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) #define NFS3_accessres_sz (1+NFS3_post_op_attr_sz+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) #define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) #define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define NFS3_createres_sz (1+NFS3_post_op_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define NFS3_fsstatres_sz (1+NFS3_post_op_attr_sz+13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define NFS3_fsinfores_sz (1+NFS3_post_op_attr_sz+12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define NFS3_pathconfres_sz (1+NFS3_post_op_attr_sz+6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define NFS3_commitres_sz (1+NFS3_wcc_data_sz+2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define ACL3_getaclargs_sz (NFS3_fh_sz+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define ACL3_setaclargs_sz (NFS3_fh_sz+1+ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) #define ACL3_getaclres_sz (1+NFS3_post_op_attr_sz+1+ \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) XDR_QUADLEN(NFS_ACL_INLINE_BUFSIZE)+1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) #define ACL3_setaclres_sz (1+NFS3_post_op_attr_sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) static int nfs3_stat_to_errno(enum nfs_stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) * Map file type to S_IFMT bits
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) static const umode_t nfs_type2fmt[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) [NF3BAD] = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) [NF3REG] = S_IFREG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) [NF3DIR] = S_IFDIR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) [NF3BLK] = S_IFBLK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) [NF3CHR] = S_IFCHR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) [NF3LNK] = S_IFLNK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) [NF3SOCK] = S_IFSOCK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) [NF3FIFO] = S_IFIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static struct user_namespace *rpc_userns(const struct rpc_clnt *clnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (clnt && clnt->cl_cred)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) return clnt->cl_cred->user_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) return &init_user_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) static struct user_namespace *rpc_rqst_userns(const struct rpc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (rqstp->rq_task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return rpc_userns(rqstp->rq_task->tk_client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) return &init_user_ns;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * Encode/decode NFSv3 basic data types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) * Basic NFSv3 data types are defined in section 2.5 of RFC 1813:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * "NFS Version 3 Protocol Specification".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) * Not all basic data types have their own encoding and decoding
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) * functions. For run-time efficiency, some data types are encoded
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * or decoded inline.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) static void encode_uint32(struct xdr_stream *xdr, u32 value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) __be32 *p = xdr_reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) *p = cpu_to_be32(value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) static int decode_uint32(struct xdr_stream *xdr, u32 *value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) *value = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) static int decode_uint64(struct xdr_stream *xdr, u64 *value)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) p = xdr_inline_decode(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) xdr_decode_hyper(p, value);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) * fileid3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * typedef uint64 fileid3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static __be32 *xdr_decode_fileid3(__be32 *p, u64 *fileid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return xdr_decode_hyper(p, fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static int decode_fileid3(struct xdr_stream *xdr, u64 *fileid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return decode_uint64(xdr, fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * filename3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * typedef string filename3<>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static void encode_filename3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) const char *name, u32 length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) WARN_ON_ONCE(length > NFS3_MAXNAMLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) p = xdr_reserve_space(xdr, 4 + length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) xdr_encode_opaque(p, name, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) static int decode_inline_filename3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) const char **name, u32 *length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) if (count > NFS3_MAXNAMLEN)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) goto out_nametoolong;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) p = xdr_inline_decode(xdr, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) *name = (const char *)p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) *length = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) out_nametoolong:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) dprintk("NFS: returned filename too long: %u\n", count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) return -ENAMETOOLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) * nfspath3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) * typedef string nfspath3<>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static void encode_nfspath3(struct xdr_stream *xdr, struct page **pages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) const u32 length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) encode_uint32(xdr, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) xdr_write_pages(xdr, pages, 0, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) static int decode_nfspath3(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) u32 recvd, count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) count = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) if (unlikely(count >= xdr->buf->page_len || count > NFS3_MAXPATHLEN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) goto out_nametoolong;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) recvd = xdr_read_pages(xdr, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (unlikely(count > recvd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) goto out_cheating;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) xdr_terminate_string(xdr->buf, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) out_nametoolong:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) dprintk("NFS: returned pathname too long: %u\n", count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) return -ENAMETOOLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) out_cheating:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) dprintk("NFS: server cheating in pathname result: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) "count %u > recvd %u\n", count, recvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) * cookie3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * typedef uint64 cookie3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) static __be32 *xdr_encode_cookie3(__be32 *p, u64 cookie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) return xdr_encode_hyper(p, cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) static int decode_cookie3(struct xdr_stream *xdr, u64 *cookie)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return decode_uint64(xdr, cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) * cookieverf3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) * typedef opaque cookieverf3[NFS3_COOKIEVERFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) static __be32 *xdr_encode_cookieverf3(__be32 *p, const __be32 *verifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) memcpy(p, verifier, NFS3_COOKIEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) return p + XDR_QUADLEN(NFS3_COOKIEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) static int decode_cookieverf3(struct xdr_stream *xdr, __be32 *verifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) p = xdr_inline_decode(xdr, NFS3_COOKIEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) memcpy(verifier, p, NFS3_COOKIEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) * createverf3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) * typedef opaque createverf3[NFS3_CREATEVERFSIZE];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) static void encode_createverf3(struct xdr_stream *xdr, const __be32 *verifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) p = xdr_reserve_space(xdr, NFS3_CREATEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) memcpy(p, verifier, NFS3_CREATEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) static int decode_writeverf3(struct xdr_stream *xdr, struct nfs_write_verifier *verifier)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) p = xdr_inline_decode(xdr, NFS3_WRITEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) memcpy(verifier->data, p, NFS3_WRITEVERFSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) * size3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) * typedef uint64 size3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) static __be32 *xdr_decode_size3(__be32 *p, u64 *size)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) return xdr_decode_hyper(p, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * nfsstat3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) * enum nfsstat3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) * NFS3_OK = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) * ...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) * }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) #define NFS3_OK NFS_OK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static int decode_nfsstat3(struct xdr_stream *xdr, enum nfs_stat *status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) if (unlikely(*p != cpu_to_be32(NFS3_OK)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) *status = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) *status = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) trace_nfs_xdr_status(xdr, (int)*status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) * ftype3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * enum ftype3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * NF3REG = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * NF3DIR = 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * NF3BLK = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * NF3CHR = 4,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * NF3LNK = 5,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * NF3SOCK = 6,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * NF3FIFO = 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) static void encode_ftype3(struct xdr_stream *xdr, const u32 type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) encode_uint32(xdr, type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) static __be32 *xdr_decode_ftype3(__be32 *p, umode_t *mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) u32 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) type = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if (type > NF3FIFO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) type = NF3NON;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) *mode = nfs_type2fmt[type];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) * specdata3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) * struct specdata3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) * uint32 specdata1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) * uint32 specdata2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) static void encode_specdata3(struct xdr_stream *xdr, const dev_t rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) p = xdr_reserve_space(xdr, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) *p++ = cpu_to_be32(MAJOR(rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) *p = cpu_to_be32(MINOR(rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) static __be32 *xdr_decode_specdata3(__be32 *p, dev_t *rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) unsigned int major, minor;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) major = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) minor = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) *rdev = MKDEV(major, minor);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) if (MAJOR(*rdev) != major || MINOR(*rdev) != minor)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) *rdev = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * nfs_fh3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * struct nfs_fh3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) * opaque data<NFS3_FHSIZE>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) static void encode_nfs_fh3(struct xdr_stream *xdr, const struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) WARN_ON_ONCE(fh->size > NFS3_FHSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) p = xdr_reserve_space(xdr, 4 + fh->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) xdr_encode_opaque(p, fh->data, fh->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) static int decode_nfs_fh3(struct xdr_stream *xdr, struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) u32 length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) length = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) if (unlikely(length > NFS3_FHSIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) goto out_toobig;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) p = xdr_inline_decode(xdr, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) fh->size = length;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) memcpy(fh->data, p, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) out_toobig:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) dprintk("NFS: file handle size (%u) too big\n", length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) return -E2BIG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) static void zero_nfs_fh3(struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) memset(fh, 0, sizeof(*fh));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) * nfstime3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) * struct nfstime3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) * uint32 seconds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) * uint32 nseconds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) static __be32 *xdr_encode_nfstime3(__be32 *p, const struct timespec64 *timep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) *p++ = cpu_to_be32((u32)timep->tv_sec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) *p++ = cpu_to_be32(timep->tv_nsec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) static __be32 *xdr_decode_nfstime3(__be32 *p, struct timespec64 *timep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) timep->tv_sec = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) timep->tv_nsec = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) * sattr3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) * enum time_how {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) * DONT_CHANGE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) * SET_TO_SERVER_TIME = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) * SET_TO_CLIENT_TIME = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) * union set_mode3 switch (bool set_it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) * mode3 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) * union set_uid3 switch (bool set_it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) * uid3 uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) * union set_gid3 switch (bool set_it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) * gid3 gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) * union set_size3 switch (bool set_it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) * size3 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) * union set_atime switch (time_how set_it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) * case SET_TO_CLIENT_TIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) * nfstime3 atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) * union set_mtime switch (time_how set_it) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) * case SET_TO_CLIENT_TIME:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) * nfstime3 mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) * struct sattr3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) * set_mode3 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) * set_uid3 uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) * set_gid3 gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) * set_size3 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) * set_atime atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) * set_mtime mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static void encode_sattr3(struct xdr_stream *xdr, const struct iattr *attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) u32 nbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) * In order to make only a single xdr_reserve_space() call,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) * pre-compute the total number of bytes to be reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) * Six boolean values, one for each set_foo field, are always
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) * present in the encoded result, so start there.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) nbytes = 6 * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) if (attr->ia_valid & ATTR_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) nbytes += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) if (attr->ia_valid & ATTR_UID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) nbytes += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) if (attr->ia_valid & ATTR_GID)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) nbytes += 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) if (attr->ia_valid & ATTR_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) nbytes += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) if (attr->ia_valid & ATTR_ATIME_SET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) nbytes += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) if (attr->ia_valid & ATTR_MTIME_SET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) nbytes += 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) p = xdr_reserve_space(xdr, nbytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (attr->ia_valid & ATTR_MODE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) *p++ = cpu_to_be32(attr->ia_mode & S_IALLUGO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (attr->ia_valid & ATTR_UID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) *p++ = cpu_to_be32(from_kuid_munged(userns, attr->ia_uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) if (attr->ia_valid & ATTR_GID) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) *p++ = cpu_to_be32(from_kgid_munged(userns, attr->ia_gid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) if (attr->ia_valid & ATTR_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) p = xdr_encode_hyper(p, (u64)attr->ia_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) if (attr->ia_valid & ATTR_ATIME_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) *p++ = xdr_two;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) p = xdr_encode_nfstime3(p, &attr->ia_atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) } else if (attr->ia_valid & ATTR_ATIME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) if (attr->ia_valid & ATTR_MTIME_SET) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) *p++ = xdr_two;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) xdr_encode_nfstime3(p, &attr->ia_mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) } else if (attr->ia_valid & ATTR_MTIME) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) *p = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) *p = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) * fattr3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) * struct fattr3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) * ftype3 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) * mode3 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) * uint32 nlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) * uid3 uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) * gid3 gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) * size3 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) * size3 used;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) * specdata3 rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) * uint64 fsid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) * fileid3 fileid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) * nfstime3 atime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) * nfstime3 mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) * nfstime3 ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) static int decode_fattr3(struct xdr_stream *xdr, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) umode_t fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) p = xdr_inline_decode(xdr, NFS3_fattr_sz << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) p = xdr_decode_ftype3(p, &fmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) fattr->mode = (be32_to_cpup(p++) & ~S_IFMT) | fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) fattr->nlink = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) fattr->uid = make_kuid(userns, be32_to_cpup(p++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) if (!uid_valid(fattr->uid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) goto out_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) fattr->gid = make_kgid(userns, be32_to_cpup(p++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (!gid_valid(fattr->gid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) goto out_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) p = xdr_decode_size3(p, &fattr->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) p = xdr_decode_size3(p, &fattr->du.nfs3.used);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) p = xdr_decode_specdata3(p, &fattr->rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) p = xdr_decode_hyper(p, &fattr->fsid.major);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) fattr->fsid.minor = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) p = xdr_decode_fileid3(p, &fattr->fileid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) p = xdr_decode_nfstime3(p, &fattr->atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) p = xdr_decode_nfstime3(p, &fattr->mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) xdr_decode_nfstime3(p, &fattr->ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) fattr->change_attr = nfs_timespec_to_change_attr(&fattr->ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) fattr->valid |= NFS_ATTR_FATTR_V3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) out_uid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) dprintk("NFS: returned invalid uid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) out_gid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) dprintk("NFS: returned invalid gid\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) * post_op_attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) * union post_op_attr switch (bool attributes_follow) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) * fattr3 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) * case FALSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) static int decode_post_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) if (*p != xdr_zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) return decode_fattr3(xdr, fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) * wcc_attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) * struct wcc_attr {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) * size3 size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) * nfstime3 mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) * nfstime3 ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) static int decode_wcc_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) p = xdr_inline_decode(xdr, NFS3_wcc_attr_sz << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) fattr->valid |= NFS_ATTR_FATTR_PRESIZE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) | NFS_ATTR_FATTR_PRECHANGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) | NFS_ATTR_FATTR_PREMTIME
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) | NFS_ATTR_FATTR_PRECTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) p = xdr_decode_size3(p, &fattr->pre_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) p = xdr_decode_nfstime3(p, &fattr->pre_mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) xdr_decode_nfstime3(p, &fattr->pre_ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) fattr->pre_change_attr = nfs_timespec_to_change_attr(&fattr->pre_ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) * pre_op_attr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) * union pre_op_attr switch (bool attributes_follow) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) * wcc_attr attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) * case FALSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) * wcc_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) * struct wcc_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) * pre_op_attr before;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) * post_op_attr after;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) static int decode_pre_op_attr(struct xdr_stream *xdr, struct nfs_fattr *fattr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) if (*p != xdr_zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) return decode_wcc_attr(xdr, fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) static int decode_wcc_data(struct xdr_stream *xdr, struct nfs_fattr *fattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) error = decode_pre_op_attr(xdr, fattr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753) error = decode_post_op_attr(xdr, fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) * post_op_fh3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) * union post_op_fh3 switch (bool handle_follows) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) * nfs_fh3 handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) * case FALSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) static int decode_post_op_fh3(struct xdr_stream *xdr, struct nfs_fh *fh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) __be32 *p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) if (*p != xdr_zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) return decode_nfs_fh3(xdr, fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) zero_nfs_fh3(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) * diropargs3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) * struct diropargs3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) * nfs_fh3 dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) * filename3 name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) static void encode_diropargs3(struct xdr_stream *xdr, const struct nfs_fh *fh,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) const char *name, u32 length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) encode_nfs_fh3(xdr, fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) encode_filename3(xdr, name, length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) * NFSv3 XDR encode functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) * NFSv3 argument types are defined in section 3.3 of RFC 1813:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) * "NFS Version 3 Protocol Specification".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) * 3.3.1 GETATTR3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) * struct GETATTR3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) * nfs_fh3 object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) static void nfs3_xdr_enc_getattr3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) const struct nfs_fh *fh = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) encode_nfs_fh3(xdr, fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) * 3.3.2 SETATTR3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) * union sattrguard3 switch (bool check) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) * case TRUE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) * nfstime3 obj_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) * case FALSE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) * struct SETATTR3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) * nfs_fh3 object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) * sattr3 new_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) * sattrguard3 guard;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) static void encode_sattrguard3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) const struct nfs3_sattrargs *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) if (args->guard) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) p = xdr_reserve_space(xdr, 4 + 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) xdr_encode_nfstime3(p, &args->guardtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) p = xdr_reserve_space(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845) *p = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) static void nfs3_xdr_enc_setattr3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) const struct nfs3_sattrargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) encode_sattr3(xdr, args->sattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) encode_sattrguard3(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) * 3.3.3 LOOKUP3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) * struct LOOKUP3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) * diropargs3 what;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) static void nfs3_xdr_enc_lookup3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) const struct nfs3_diropargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) encode_diropargs3(xdr, args->fh, args->name, args->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) * 3.3.4 ACCESS3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) * struct ACCESS3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) * nfs_fh3 object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) * uint32 access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) static void encode_access3args(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) const struct nfs3_accessargs *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) encode_uint32(xdr, args->access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) static void nfs3_xdr_enc_access3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) const struct nfs3_accessargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) encode_access3args(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) * 3.3.5 READLINK3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) * struct READLINK3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) * nfs_fh3 symlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) static void nfs3_xdr_enc_readlink3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) const struct nfs3_readlinkargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) rpc_prepare_reply_pages(req, args->pages, args->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) args->pglen, NFS3_readlinkres_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) * 3.3.6 READ3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) * struct READ3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) * nfs_fh3 file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) * offset3 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) * count3 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) static void encode_read3args(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) const struct nfs_pgio_args *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) p = xdr_reserve_space(xdr, 8 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) *p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) static void nfs3_xdr_enc_read3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) const struct nfs_pgio_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) unsigned int replen = args->replen ? args->replen : NFS3_readres_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) encode_read3args(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) rpc_prepare_reply_pages(req, args->pages, args->pgbase,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) args->count, replen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) req->rq_rcv_buf.flags |= XDRBUF_READ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) * 3.3.7 WRITE3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) * enum stable_how {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) * UNSTABLE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) * DATA_SYNC = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) * FILE_SYNC = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960) * struct WRITE3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) * nfs_fh3 file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) * offset3 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) * count3 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) * stable_how stable;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965) * opaque data<>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) static void encode_write3args(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) const struct nfs_pgio_args *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) p = xdr_reserve_space(xdr, 8 + 4 + 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) *p++ = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) *p++ = cpu_to_be32(args->stable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) *p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) xdr_write_pages(xdr, args->pages, args->pgbase, args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) static void nfs3_xdr_enc_write3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) const struct nfs_pgio_args *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) encode_write3args(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) xdr->buf->flags |= XDRBUF_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) * 3.3.8 CREATE3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) * enum createmode3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997) * UNCHECKED = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) * GUARDED = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) * EXCLUSIVE = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) * union createhow3 switch (createmode3 mode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) * case UNCHECKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) * case GUARDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) * sattr3 obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) * case EXCLUSIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) * createverf3 verf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) * struct CREATE3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) * diropargs3 where;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) * createhow3 how;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) static void encode_createhow3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) const struct nfs3_createargs *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) encode_uint32(xdr, args->createmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) switch (args->createmode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) case NFS3_CREATE_UNCHECKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) case NFS3_CREATE_GUARDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) encode_sattr3(xdr, args->sattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) case NFS3_CREATE_EXCLUSIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) encode_createverf3(xdr, args->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) static void nfs3_xdr_enc_create3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) const struct nfs3_createargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) encode_diropargs3(xdr, args->fh, args->name, args->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) encode_createhow3(xdr, args, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) * 3.3.9 MKDIR3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) * struct MKDIR3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) * diropargs3 where;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) * sattr3 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static void nfs3_xdr_enc_mkdir3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) const struct nfs3_mkdirargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) encode_diropargs3(xdr, args->fh, args->name, args->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) encode_sattr3(xdr, args->sattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) * 3.3.10 SYMLINK3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) * struct symlinkdata3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) * sattr3 symlink_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) * nfspath3 symlink_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) * struct SYMLINK3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) * diropargs3 where;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) * symlinkdata3 symlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) static void encode_symlinkdata3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) const void *data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) const struct nfs3_symlinkargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) encode_sattr3(xdr, args->sattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) encode_nfspath3(xdr, args->pages, args->pathlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) static void nfs3_xdr_enc_symlink3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) const struct nfs3_symlinkargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) encode_diropargs3(xdr, args->fromfh, args->fromname, args->fromlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) encode_symlinkdata3(xdr, args, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) xdr->buf->flags |= XDRBUF_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) * 3.3.11 MKNOD3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) * struct devicedata3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) * sattr3 dev_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) * specdata3 spec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) * union mknoddata3 switch (ftype3 type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) * case NF3CHR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) * case NF3BLK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) * devicedata3 device;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) * case NF3SOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) * case NF3FIFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) * sattr3 pipe_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) * struct MKNOD3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) * diropargs3 where;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) * mknoddata3 what;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) static void encode_devicedata3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) const struct nfs3_mknodargs *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) encode_sattr3(xdr, args->sattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) encode_specdata3(xdr, args->rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) static void encode_mknoddata3(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) const struct nfs3_mknodargs *args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) encode_ftype3(xdr, args->type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) switch (args->type) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) case NF3CHR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) case NF3BLK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) encode_devicedata3(xdr, args, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) case NF3SOCK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) case NF3FIFO:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) encode_sattr3(xdr, args->sattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) case NF3REG:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) case NF3DIR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) static void nfs3_xdr_enc_mknod3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) const struct nfs3_mknodargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) encode_diropargs3(xdr, args->fh, args->name, args->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) encode_mknoddata3(xdr, args, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) * 3.3.12 REMOVE3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) * struct REMOVE3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) * diropargs3 object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) static void nfs3_xdr_enc_remove3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) const struct nfs_removeargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) encode_diropargs3(xdr, args->fh, args->name.name, args->name.len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) * 3.3.14 RENAME3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) * struct RENAME3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) * diropargs3 from;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) * diropargs3 to;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) static void nfs3_xdr_enc_rename3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) const struct nfs_renameargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) const struct qstr *old = args->old_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) const struct qstr *new = args->new_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) encode_diropargs3(xdr, args->old_dir, old->name, old->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) encode_diropargs3(xdr, args->new_dir, new->name, new->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) * 3.3.15 LINK3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) * struct LINK3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) * nfs_fh3 file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) * diropargs3 link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) static void nfs3_xdr_enc_link3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) const struct nfs3_linkargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) encode_nfs_fh3(xdr, args->fromfh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) encode_diropargs3(xdr, args->tofh, args->toname, args->tolen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) * 3.3.16 READDIR3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) * struct READDIR3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) * nfs_fh3 dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) * cookie3 cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) * cookieverf3 cookieverf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) * count3 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) static void encode_readdir3args(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) const struct nfs3_readdirargs *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) p = xdr_encode_cookie3(p, args->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) p = xdr_encode_cookieverf3(p, args->verf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) *p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) static void nfs3_xdr_enc_readdir3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) const struct nfs3_readdirargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) encode_readdir3args(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) rpc_prepare_reply_pages(req, args->pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) args->count, NFS3_readdirres_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) * 3.3.17 READDIRPLUS3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) * struct READDIRPLUS3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) * nfs_fh3 dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) * cookie3 cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) * cookieverf3 cookieverf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) * count3 dircount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) * count3 maxcount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) static void encode_readdirplus3args(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) const struct nfs3_readdirargs *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) p = xdr_reserve_space(xdr, 8 + NFS3_COOKIEVERFSIZE + 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) p = xdr_encode_cookie3(p, args->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) p = xdr_encode_cookieverf3(p, args->verf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) * readdirplus: need dircount + buffer size.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) * We just make sure we make dircount big enough
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) *p++ = cpu_to_be32(args->count >> 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) *p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) static void nfs3_xdr_enc_readdirplus3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) const struct nfs3_readdirargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) encode_readdirplus3args(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) rpc_prepare_reply_pages(req, args->pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) args->count, NFS3_readdirres_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) * 3.3.21 COMMIT3args
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) * struct COMMIT3args {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) * nfs_fh3 file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) * offset3 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) * count3 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) static void encode_commit3args(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) const struct nfs_commitargs *args)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) p = xdr_reserve_space(xdr, 8 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) p = xdr_encode_hyper(p, args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) *p = cpu_to_be32(args->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) static void nfs3_xdr_enc_commit3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) const struct nfs_commitargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) encode_commit3args(xdr, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) #ifdef CONFIG_NFS_V3_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) static void nfs3_xdr_enc_getacl3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) const struct nfs3_getaclargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) encode_nfs_fh3(xdr, args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) encode_uint32(xdr, args->mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) if (args->mask & (NFS_ACL | NFS_DFACL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) rpc_prepare_reply_pages(req, args->pages, 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) NFSACL_MAXPAGES << PAGE_SHIFT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) ACL3_getaclres_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) req->rq_rcv_buf.flags |= XDRBUF_SPARSE_PAGES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) static void nfs3_xdr_enc_setacl3args(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) const void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) const struct nfs3_setaclargs *args = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) unsigned int base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) encode_nfs_fh3(xdr, NFS_FH(args->inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) encode_uint32(xdr, args->mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) base = req->rq_slen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) if (args->npages != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) xdr_write_pages(xdr, args->pages, 0, args->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) xdr_reserve_space(xdr, args->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) error = nfsacl_encode(xdr->buf, base, args->inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) (args->mask & NFS_ACL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) args->acl_access : NULL, 1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) /* FIXME: this is just broken */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) BUG_ON(error < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) error = nfsacl_encode(xdr->buf, base + error, args->inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) (args->mask & NFS_DFACL) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) args->acl_default : NULL, 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) NFS_ACL_DEFAULT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) BUG_ON(error < 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) #endif /* CONFIG_NFS_V3_ACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) * NFSv3 XDR decode functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) * NFSv3 result types are defined in section 3.3 of RFC 1813:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) * "NFS Version 3 Protocol Specification".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) * 3.3.1 GETATTR3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) * struct GETATTR3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) * fattr3 obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) * union GETATTR3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) * GETATTR3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) * void;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) static int nfs3_xdr_dec_getattr3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) void *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) error = decode_fattr3(xdr, result, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) * 3.3.2 SETATTR3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) * struct SETATTR3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) * wcc_data obj_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) * struct SETATTR3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) * wcc_data obj_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) * union SETATTR3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) * SETATTR3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) * SETATTR3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) static int nfs3_xdr_dec_setattr3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) void *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) error = decode_wcc_data(xdr, result, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) * 3.3.3 LOOKUP3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) * struct LOOKUP3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) * nfs_fh3 object;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) * post_op_attr dir_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) * struct LOOKUP3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) * post_op_attr dir_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) * union LOOKUP3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) * LOOKUP3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) * LOOKUP3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) static int nfs3_xdr_dec_lookup3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) struct user_namespace *userns = rpc_rqst_userns(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) struct nfs3_diropres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) error = decode_nfs_fh3(xdr, result->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) error = decode_post_op_attr(xdr, result->fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) error = decode_post_op_attr(xdr, result->dir_attr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) error = decode_post_op_attr(xdr, result->dir_attr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) * 3.3.4 ACCESS3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) * struct ACCESS3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) * uint32 access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) * struct ACCESS3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) * union ACCESS3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) * ACCESS3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) * ACCESS3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) static int nfs3_xdr_dec_access3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) struct nfs3_accessres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) error = decode_uint32(xdr, &result->access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) * 3.3.5 READLINK3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) * struct READLINK3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) * post_op_attr symlink_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) * nfspath3 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) * struct READLINK3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) * post_op_attr symlink_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) * union READLINK3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) * READLINK3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) * READLINK3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) static int nfs3_xdr_dec_readlink3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) void *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) error = decode_post_op_attr(xdr, result, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) error = decode_nfspath3(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) * 3.3.6 READ3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) * struct READ3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) * post_op_attr file_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) * count3 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) * bool eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) * opaque data<>;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) * struct READ3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) * post_op_attr file_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) * union READ3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) * READ3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) * READ3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) static int decode_read3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) struct nfs_pgio_res *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) u32 eof, count, ocount, recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) p = xdr_inline_decode(xdr, 4 + 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) count = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) eof = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) ocount = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) if (unlikely(ocount != count))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) goto out_mismatch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) recvd = xdr_read_pages(xdr, count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1616) if (unlikely(count > recvd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1617) goto out_cheating;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1618) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1619) result->eof = eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1620) result->count = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1621) return count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1622) out_mismatch:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1623) dprintk("NFS: READ count doesn't match length of opaque: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1624) "count %u != ocount %u\n", count, ocount);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1625) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1626) out_cheating:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1627) dprintk("NFS: server cheating in read result: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1628) "count %u > recvd %u\n", count, recvd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1629) count = recvd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1630) eof = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1631) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1632) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1633)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1634) static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1635) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1636) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1637) struct nfs_pgio_res *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1638) unsigned int pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1639) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1640) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1642) pos = xdr_stream_pos(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1643) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1644) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1645) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1646) error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1647) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1648) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1649) result->op_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1650) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1651) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1652) result->replen = 4 + ((xdr_stream_pos(xdr) - pos) >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1653) error = decode_read3resok(xdr, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1654) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1655) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1656) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1657) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1658) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1659)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1660) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1661) * 3.3.7 WRITE3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1662) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1663) * enum stable_how {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1664) * UNSTABLE = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1665) * DATA_SYNC = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1666) * FILE_SYNC = 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1667) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1668) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1669) * struct WRITE3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1670) * wcc_data file_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1671) * count3 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1672) * stable_how committed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1673) * writeverf3 verf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1674) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1675) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1676) * struct WRITE3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1677) * wcc_data file_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1678) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1679) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1680) * union WRITE3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1681) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1682) * WRITE3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1683) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1684) * WRITE3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1685) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1686) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1687) static int decode_write3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1688) struct nfs_pgio_res *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1689) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1690) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1692) p = xdr_inline_decode(xdr, 4 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1693) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1694) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1695) result->count = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1696) result->verf->committed = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1697) if (unlikely(result->verf->committed > NFS_FILE_SYNC))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1698) goto out_badvalue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1699) if (decode_writeverf3(xdr, &result->verf->verifier))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1700) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1701) return result->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1702) out_badvalue:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1703) dprintk("NFS: bad stable_how value: %u\n", result->verf->committed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1704) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1705) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1706)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1707) static int nfs3_xdr_dec_write3res(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1708) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1709) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1710) struct nfs_pgio_res *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1711) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1712) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1713)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1714) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1715) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1716) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1717) error = decode_wcc_data(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1718) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1719) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1720) result->op_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1721) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1722) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1723) error = decode_write3resok(xdr, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1724) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1725) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1726) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1727) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1728) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1730) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1731) * 3.3.8 CREATE3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1732) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1733) * struct CREATE3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1734) * post_op_fh3 obj;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1735) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1736) * wcc_data dir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1737) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1738) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1739) * struct CREATE3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1740) * wcc_data dir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1741) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1742) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1743) * union CREATE3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1744) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1745) * CREATE3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1746) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1747) * CREATE3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1748) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1749) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1750) static int decode_create3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1751) struct nfs3_diropres *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1752) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1753) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1754) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1755)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1756) error = decode_post_op_fh3(xdr, result->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1757) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1758) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1759) error = decode_post_op_attr(xdr, result->fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1760) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1761) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1762) /* The server isn't required to return a file handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1763) * If it didn't, force the client to perform a LOOKUP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1764) * to determine the correct file handle and attribute
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1765) * values for the new object. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1766) if (result->fh->size == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1767) result->fattr->valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1768) error = decode_wcc_data(xdr, result->dir_attr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1769) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1770) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1771) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1772)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1773) static int nfs3_xdr_dec_create3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1774) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1775) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1777) struct user_namespace *userns = rpc_rqst_userns(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1778) struct nfs3_diropres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1779) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1780) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1781)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1782) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1783) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1784) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1785) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1786) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1787) error = decode_create3resok(xdr, result, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1788) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1789) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1790) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1791) error = decode_wcc_data(xdr, result->dir_attr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1792) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1793) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1794) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1795) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1796)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1797) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1798) * 3.3.12 REMOVE3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1799) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1800) * struct REMOVE3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1801) * wcc_data dir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1802) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1803) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1804) * struct REMOVE3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1805) * wcc_data dir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1806) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1807) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1808) * union REMOVE3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1809) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1810) * REMOVE3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1811) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1812) * REMOVE3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1813) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1814) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1815) static int nfs3_xdr_dec_remove3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1816) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1817) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1818) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1819) struct nfs_removeres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1820) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1821) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1823) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1824) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1825) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1826) error = decode_wcc_data(xdr, result->dir_attr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1827) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1828) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1829) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1830) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1831) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1832) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1833) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1834) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1835) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1836)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1837) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1838) * 3.3.14 RENAME3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1839) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1840) * struct RENAME3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1841) * wcc_data fromdir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1842) * wcc_data todir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1843) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1844) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1845) * struct RENAME3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1846) * wcc_data fromdir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1847) * wcc_data todir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1848) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1849) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1850) * union RENAME3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1851) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1852) * RENAME3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1853) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1854) * RENAME3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1855) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1856) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1857) static int nfs3_xdr_dec_rename3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1858) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1859) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1860) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1861) struct user_namespace *userns = rpc_rqst_userns(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1862) struct nfs_renameres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1863) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1864) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1866) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1867) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1868) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1869) error = decode_wcc_data(xdr, result->old_fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1870) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1871) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1872) error = decode_wcc_data(xdr, result->new_fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1873) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1874) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1875) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1876) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1877) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1878) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1879) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1880) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1881) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1882)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1883) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1884) * 3.3.15 LINK3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1885) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1886) * struct LINK3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1887) * post_op_attr file_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1888) * wcc_data linkdir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1889) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1890) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1891) * struct LINK3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1892) * post_op_attr file_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1893) * wcc_data linkdir_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1894) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1895) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1896) * union LINK3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1897) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1898) * LINK3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1899) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1900) * LINK3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1901) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1902) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1903) static int nfs3_xdr_dec_link3res(struct rpc_rqst *req, struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1904) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1905) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1906) struct user_namespace *userns = rpc_rqst_userns(req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1907) struct nfs3_linkres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1908) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1909) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1911) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1912) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1913) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1914) error = decode_post_op_attr(xdr, result->fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1915) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1916) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1917) error = decode_wcc_data(xdr, result->dir_attr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1918) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1919) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1920) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1921) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1922) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1923) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1924) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1925) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1926) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1927)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1928) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1929) * nfs3_decode_dirent - Decode a single NFSv3 directory entry stored in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1930) * the local page cache
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1931) * @xdr: XDR stream where entry resides
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1932) * @entry: buffer to fill in with entry data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1933) * @plus: boolean indicating whether this should be a readdirplus entry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1934) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1935) * Returns zero if successful, otherwise a negative errno value is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1936) * returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1937) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1938) * This function is not invoked during READDIR reply decoding, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1939) * rather whenever an application invokes the getdents(2) system call
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1940) * on a directory already in our cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1941) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1942) * 3.3.16 entry3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1943) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1944) * struct entry3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1945) * fileid3 fileid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1946) * filename3 name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1947) * cookie3 cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1948) * fhandle3 filehandle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1949) * post_op_attr3 attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1950) * entry3 *nextentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1951) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1952) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1953) * 3.3.17 entryplus3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1954) * struct entryplus3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1955) * fileid3 fileid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1956) * filename3 name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1957) * cookie3 cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1958) * post_op_attr name_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1959) * post_op_fh3 name_handle;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1960) * entryplus3 *nextentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1961) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1962) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1963) int nfs3_decode_dirent(struct xdr_stream *xdr, struct nfs_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1964) bool plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1965) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1966) struct user_namespace *userns = rpc_userns(entry->server->client);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1967) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1968) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1969) u64 new_cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1971) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1972) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1973) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1974) if (*p == xdr_zero) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1975) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1976) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1977) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1978) if (*p == xdr_zero)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1979) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1980) entry->eof = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1981) return -EBADCOOKIE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1982) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1983)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1984) error = decode_fileid3(xdr, &entry->ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1985) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1986) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1988) error = decode_inline_filename3(xdr, &entry->name, &entry->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1989) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1990) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1991)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1992) error = decode_cookie3(xdr, &new_cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1993) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1994) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1995)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1996) entry->d_type = DT_UNKNOWN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1998) if (plus) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1999) entry->fattr->valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2000) error = decode_post_op_attr(xdr, entry->fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2001) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2002) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2003) if (entry->fattr->valid & NFS_ATTR_FATTR_V3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2004) entry->d_type = nfs_umode_to_dtype(entry->fattr->mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2006) if (entry->fattr->fileid != entry->ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2007) entry->fattr->mounted_on_fileid = entry->ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2008) entry->fattr->valid |= NFS_ATTR_FATTR_MOUNTED_ON_FILEID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2011) /* In fact, a post_op_fh3: */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2012) p = xdr_inline_decode(xdr, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2013) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2014) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2015) if (*p != xdr_zero) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2016) error = decode_nfs_fh3(xdr, entry->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2017) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2018) return -EAGAIN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2019) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2020) zero_nfs_fh3(entry->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2021) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2022)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2023) entry->prev_cookie = entry->cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2024) entry->cookie = new_cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2026) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2027) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2028)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2029) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2030) * 3.3.16 READDIR3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2031) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2032) * struct dirlist3 {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2033) * entry3 *entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2034) * bool eof;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2035) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2036) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2037) * struct READDIR3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2038) * post_op_attr dir_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2039) * cookieverf3 cookieverf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2040) * dirlist3 reply;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2041) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2042) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2043) * struct READDIR3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2044) * post_op_attr dir_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2045) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2046) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2047) * union READDIR3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2048) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2049) * READDIR3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2050) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2051) * READDIR3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2052) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2053) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2054) * Read the directory contents into the page cache, but otherwise
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2055) * don't touch them. The actual decoding is done by nfs3_decode_entry()
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2056) * during subsequent nfs_readdir() calls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2057) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2058) static int decode_dirlist3(struct xdr_stream *xdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2059) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2060) return xdr_read_pages(xdr, xdr->buf->page_len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2061) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2062)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2063) static int decode_readdir3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2064) struct nfs3_readdirres *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2065) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2066) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2067) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2068)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2069) error = decode_post_op_attr(xdr, result->dir_attr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2070) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2071) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2072) /* XXX: do we need to check if result->verf != NULL ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2073) error = decode_cookieverf3(xdr, result->verf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2074) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2075) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2076) error = decode_dirlist3(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2077) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2078) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2081) static int nfs3_xdr_dec_readdir3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2082) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2083) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2084) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2085) struct nfs3_readdirres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2086) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2087) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2088)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2089) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2090) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2091) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2092) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2093) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2094) error = decode_readdir3resok(xdr, result, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2095) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2096) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2097) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2098) error = decode_post_op_attr(xdr, result->dir_attr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2099) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2100) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2101) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2102) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2104) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2105) * 3.3.18 FSSTAT3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2106) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2107) * struct FSSTAT3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2108) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2109) * size3 tbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2110) * size3 fbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2111) * size3 abytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2112) * size3 tfiles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2113) * size3 ffiles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2114) * size3 afiles;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2115) * uint32 invarsec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2116) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2117) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2118) * struct FSSTAT3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2119) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2120) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2121) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2122) * union FSSTAT3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2123) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2124) * FSSTAT3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2125) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2126) * FSSTAT3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2127) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2128) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2129) static int decode_fsstat3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2130) struct nfs_fsstat *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2132) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2134) p = xdr_inline_decode(xdr, 8 * 6 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2135) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2136) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2137) p = xdr_decode_size3(p, &result->tbytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2138) p = xdr_decode_size3(p, &result->fbytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2139) p = xdr_decode_size3(p, &result->abytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2140) p = xdr_decode_size3(p, &result->tfiles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2141) p = xdr_decode_size3(p, &result->ffiles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2142) xdr_decode_size3(p, &result->afiles);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2143) /* ignore invarsec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2144) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2147) static int nfs3_xdr_dec_fsstat3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2148) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2149) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2151) struct nfs_fsstat *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2152) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2153) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2155) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2156) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2157) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2158) error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2159) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2160) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2161) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2162) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2163) error = decode_fsstat3resok(xdr, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2164) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2165) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2166) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2167) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2168) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2170) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2171) * 3.3.19 FSINFO3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2172) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2173) * struct FSINFO3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2174) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2175) * uint32 rtmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2176) * uint32 rtpref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2177) * uint32 rtmult;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2178) * uint32 wtmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2179) * uint32 wtpref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2180) * uint32 wtmult;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2181) * uint32 dtpref;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2182) * size3 maxfilesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2183) * nfstime3 time_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2184) * uint32 properties;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2185) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2186) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2187) * struct FSINFO3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2188) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2189) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2190) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2191) * union FSINFO3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2192) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2193) * FSINFO3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2194) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2195) * FSINFO3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2196) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2197) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2198) static int decode_fsinfo3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2199) struct nfs_fsinfo *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2200) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2201) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2203) p = xdr_inline_decode(xdr, 4 * 7 + 8 + 8 + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2204) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2205) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2206) result->rtmax = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2207) result->rtpref = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2208) result->rtmult = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2209) result->wtmax = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2210) result->wtpref = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2211) result->wtmult = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2212) result->dtpref = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2213) p = xdr_decode_size3(p, &result->maxfilesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2214) xdr_decode_nfstime3(p, &result->time_delta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2216) /* ignore properties */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2217) result->lease_time = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2218) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2221) static int nfs3_xdr_dec_fsinfo3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2222) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2223) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2224) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2225) struct nfs_fsinfo *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2226) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2227) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2229) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2230) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2231) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2232) error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2233) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2234) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2235) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2236) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2237) error = decode_fsinfo3resok(xdr, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2238) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2239) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2240) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2241) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2244) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2245) * 3.3.20 PATHCONF3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2246) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2247) * struct PATHCONF3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2248) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2249) * uint32 linkmax;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2250) * uint32 name_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2251) * bool no_trunc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2252) * bool chown_restricted;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2253) * bool case_insensitive;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2254) * bool case_preserving;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2255) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2256) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2257) * struct PATHCONF3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2258) * post_op_attr obj_attributes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2259) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2260) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2261) * union PATHCONF3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2262) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2263) * PATHCONF3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2264) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2265) * PATHCONF3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2266) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2267) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2268) static int decode_pathconf3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2269) struct nfs_pathconf *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2270) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2271) __be32 *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2272)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2273) p = xdr_inline_decode(xdr, 4 * 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2274) if (unlikely(!p))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2275) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2276) result->max_link = be32_to_cpup(p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2277) result->max_namelen = be32_to_cpup(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2278) /* ignore remaining fields */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2279) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2280) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2281)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2282) static int nfs3_xdr_dec_pathconf3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2283) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2284) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2285) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2286) struct nfs_pathconf *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2287) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2288) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2290) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2291) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2292) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2293) error = decode_post_op_attr(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2294) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2295) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2296) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2297) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2298) error = decode_pathconf3resok(xdr, result);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2299) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2300) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2301) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2302) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2305) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2306) * 3.3.21 COMMIT3res
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2307) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2308) * struct COMMIT3resok {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2309) * wcc_data file_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2310) * writeverf3 verf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2311) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2312) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2313) * struct COMMIT3resfail {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2314) * wcc_data file_wcc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2315) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2316) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2317) * union COMMIT3res switch (nfsstat3 status) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2318) * case NFS3_OK:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2319) * COMMIT3resok resok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2320) * default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2321) * COMMIT3resfail resfail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2322) * };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2323) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2324) static int nfs3_xdr_dec_commit3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2325) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2326) void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2327) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2328) struct nfs_commitres *result = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2329) struct nfs_writeverf *verf = result->verf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2330) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2331) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2333) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2334) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2335) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2336) error = decode_wcc_data(xdr, result->fattr, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2337) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2338) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2339) result->op_status = status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2340) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2341) goto out_status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2342) error = decode_writeverf3(xdr, &verf->verifier);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2343) if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2344) verf->committed = NFS_FILE_SYNC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2345) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2346) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2347) out_status:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2348) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2349) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2351) #ifdef CONFIG_NFS_V3_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2352)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2353) static inline int decode_getacl3resok(struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2354) struct nfs3_getaclres *result,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2355) struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2357) struct posix_acl **acl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2358) unsigned int *aclcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2359) size_t hdrlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2360) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2361)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2362) error = decode_post_op_attr(xdr, result->fattr, userns);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2363) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2364) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2365) error = decode_uint32(xdr, &result->mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2366) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2367) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2368) error = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2369) if (result->mask & ~(NFS_ACL|NFS_ACLCNT|NFS_DFACL|NFS_DFACLCNT))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2370) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2371)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2372) hdrlen = xdr_stream_pos(xdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2374) acl = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2375) if (result->mask & NFS_ACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2376) acl = &result->acl_access;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2377) aclcnt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2378) if (result->mask & NFS_ACLCNT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2379) aclcnt = &result->acl_access_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2380) error = nfsacl_decode(xdr->buf, hdrlen, aclcnt, acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2381) if (unlikely(error <= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2382) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2384) acl = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2385) if (result->mask & NFS_DFACL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2386) acl = &result->acl_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2387) aclcnt = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2388) if (result->mask & NFS_DFACLCNT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2389) aclcnt = &result->acl_default_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2390) error = nfsacl_decode(xdr->buf, hdrlen + error, aclcnt, acl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2391) if (unlikely(error <= 0))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2392) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2393) error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2394) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2395) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2398) static int nfs3_xdr_dec_getacl3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2399) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2400) void *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2401) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2402) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2403) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2405) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2406) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2407) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2408) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2409) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2410) error = decode_getacl3resok(xdr, result, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2411) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2412) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2413) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2414) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2416)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2417) static int nfs3_xdr_dec_setacl3res(struct rpc_rqst *req,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2418) struct xdr_stream *xdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2419) void *result)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2420) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2421) enum nfs_stat status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2422) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2423)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2424) error = decode_nfsstat3(xdr, &status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2425) if (unlikely(error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2426) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2427) if (status != NFS3_OK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2428) goto out_default;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2429) error = decode_post_op_attr(xdr, result, rpc_rqst_userns(req));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2430) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2431) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2432) out_default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2433) return nfs3_stat_to_errno(status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2434) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2435)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2436) #endif /* CONFIG_NFS_V3_ACL */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2439) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2440) * We need to translate between nfs status return values and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2441) * the local errno values which may not be the same.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2442) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2443) static const struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2444) int stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2445) int errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2446) } nfs_errtbl[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2447) { NFS_OK, 0 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2448) { NFSERR_PERM, -EPERM },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2449) { NFSERR_NOENT, -ENOENT },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2450) { NFSERR_IO, -errno_NFSERR_IO},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2451) { NFSERR_NXIO, -ENXIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2452) /* { NFSERR_EAGAIN, -EAGAIN }, */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2453) { NFSERR_ACCES, -EACCES },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2454) { NFSERR_EXIST, -EEXIST },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2455) { NFSERR_XDEV, -EXDEV },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2456) { NFSERR_NODEV, -ENODEV },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2457) { NFSERR_NOTDIR, -ENOTDIR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2458) { NFSERR_ISDIR, -EISDIR },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2459) { NFSERR_INVAL, -EINVAL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2460) { NFSERR_FBIG, -EFBIG },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2461) { NFSERR_NOSPC, -ENOSPC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2462) { NFSERR_ROFS, -EROFS },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2463) { NFSERR_MLINK, -EMLINK },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2464) { NFSERR_NAMETOOLONG, -ENAMETOOLONG },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2465) { NFSERR_NOTEMPTY, -ENOTEMPTY },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2466) { NFSERR_DQUOT, -EDQUOT },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2467) { NFSERR_STALE, -ESTALE },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2468) { NFSERR_REMOTE, -EREMOTE },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2469) #ifdef EWFLUSH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2470) { NFSERR_WFLUSH, -EWFLUSH },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2471) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2472) { NFSERR_BADHANDLE, -EBADHANDLE },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2473) { NFSERR_NOT_SYNC, -ENOTSYNC },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2474) { NFSERR_BAD_COOKIE, -EBADCOOKIE },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2475) { NFSERR_NOTSUPP, -ENOTSUPP },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2476) { NFSERR_TOOSMALL, -ETOOSMALL },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2477) { NFSERR_SERVERFAULT, -EREMOTEIO },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2478) { NFSERR_BADTYPE, -EBADTYPE },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2479) { NFSERR_JUKEBOX, -EJUKEBOX },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2480) { -1, -EIO }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2481) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2483) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2484) * nfs3_stat_to_errno - convert an NFS status code to a local errno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2485) * @status: NFS status code to convert
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2486) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2487) * Returns a local errno value, or -EIO if the NFS status code is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2488) * not recognized. This function is used jointly by NFSv2 and NFSv3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2489) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2490) static int nfs3_stat_to_errno(enum nfs_stat status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2491) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2492) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2493)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2494) for (i = 0; nfs_errtbl[i].stat != -1; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2495) if (nfs_errtbl[i].stat == (int)status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2496) return nfs_errtbl[i].errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2497) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2498) dprintk("NFS: Unrecognized nfs status value: %u\n", status);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2499) return nfs_errtbl[i].errno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2500) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2503) #define PROC(proc, argtype, restype, timer) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2504) [NFS3PROC_##proc] = { \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2505) .p_proc = NFS3PROC_##proc, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2506) .p_encode = nfs3_xdr_enc_##argtype##3args, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2507) .p_decode = nfs3_xdr_dec_##restype##3res, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2508) .p_arglen = NFS3_##argtype##args_sz, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2509) .p_replen = NFS3_##restype##res_sz, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2510) .p_timer = timer, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2511) .p_statidx = NFS3PROC_##proc, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2512) .p_name = #proc, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2513) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2514)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2515) const struct rpc_procinfo nfs3_procedures[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2516) PROC(GETATTR, getattr, getattr, 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2517) PROC(SETATTR, setattr, setattr, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2518) PROC(LOOKUP, lookup, lookup, 2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2519) PROC(ACCESS, access, access, 1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2520) PROC(READLINK, readlink, readlink, 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2521) PROC(READ, read, read, 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2522) PROC(WRITE, write, write, 4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2523) PROC(CREATE, create, create, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2524) PROC(MKDIR, mkdir, create, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2525) PROC(SYMLINK, symlink, create, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2526) PROC(MKNOD, mknod, create, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2527) PROC(REMOVE, remove, remove, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2528) PROC(RMDIR, lookup, setattr, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2529) PROC(RENAME, rename, rename, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2530) PROC(LINK, link, link, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2531) PROC(READDIR, readdir, readdir, 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2532) PROC(READDIRPLUS, readdirplus, readdir, 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2533) PROC(FSSTAT, getattr, fsstat, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2534) PROC(FSINFO, getattr, fsinfo, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2535) PROC(PATHCONF, getattr, pathconf, 0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2536) PROC(COMMIT, commit, commit, 5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2537) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2539) static unsigned int nfs_version3_counts[ARRAY_SIZE(nfs3_procedures)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2540) const struct rpc_version nfs_version3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2541) .number = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2542) .nrprocs = ARRAY_SIZE(nfs3_procedures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2543) .procs = nfs3_procedures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2544) .counts = nfs_version3_counts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2545) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2547) #ifdef CONFIG_NFS_V3_ACL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2548) static const struct rpc_procinfo nfs3_acl_procedures[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2549) [ACLPROC3_GETACL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2550) .p_proc = ACLPROC3_GETACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2551) .p_encode = nfs3_xdr_enc_getacl3args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2552) .p_decode = nfs3_xdr_dec_getacl3res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2553) .p_arglen = ACL3_getaclargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2554) .p_replen = ACL3_getaclres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2555) .p_timer = 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2556) .p_name = "GETACL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2557) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2558) [ACLPROC3_SETACL] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2559) .p_proc = ACLPROC3_SETACL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2560) .p_encode = nfs3_xdr_enc_setacl3args,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2561) .p_decode = nfs3_xdr_dec_setacl3res,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2562) .p_arglen = ACL3_setaclargs_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2563) .p_replen = ACL3_setaclres_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2564) .p_timer = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2565) .p_name = "SETACL",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2566) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2567) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2568)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2569) static unsigned int nfs3_acl_counts[ARRAY_SIZE(nfs3_acl_procedures)];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2570) const struct rpc_version nfsacl_version3 = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2571) .number = 3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2572) .nrprocs = ARRAY_SIZE(nfs3_acl_procedures),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2573) .procs = nfs3_acl_procedures,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2574) .counts = nfs3_acl_counts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2575) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2576) #endif /* CONFIG_NFS_V3_ACL */