^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) * XDR support for nfsd/protocol version 3.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1995, 1996, 1997 Olaf Kirch <okir@monad.swb.de>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * 2003-08-09 Jamie Lokier: Use htonl() for nanoseconds, not htons()!
^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/namei.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/sunrpc/svc_xprt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "xdr3.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "auth.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "netns.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "vfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #define NFSDDBG_FACILITY NFSDDBG_XDR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * Mapping of S_IF* types to NFS file types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static u32 nfs3_ftypes[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) NF3NON, NF3FIFO, NF3CHR, NF3BAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) NF3DIR, NF3BAD, NF3BLK, NF3BAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) NF3REG, NF3BAD, NF3LNK, NF3BAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) NF3SOCK, NF3BAD, NF3LNK, NF3BAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * XDR functions for basic NFS types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) encode_time3(__be32 *p, struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *p++ = htonl((u32) time->tv_sec); *p++ = htonl(time->tv_nsec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) decode_time3(__be32 *p, struct timespec64 *time)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) time->tv_sec = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) time->tv_nsec = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) decode_fh(__be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) unsigned int size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) fh_init(fhp, NFS3_FHSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) size = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) if (size > NFS3_FHSIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) memcpy(&fhp->fh_handle.fh_base, p, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) fhp->fh_handle.fh_size = size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) return p + XDR_QUADLEN(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* Helper function for NFSv3 ACL code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) __be32 *nfs3svc_decode_fh(__be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) return decode_fh(p, fhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) encode_fh(__be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) unsigned int size = fhp->fh_handle.fh_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) *p++ = htonl(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) if (size) p[XDR_QUADLEN(size)-1]=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) memcpy(p, &fhp->fh_handle.fh_base, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return p + XDR_QUADLEN(size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * Decode a file name and make sure that the path contains
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * no slashes or null bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) decode_filename(__be32 *p, char **namp, unsigned int *lenp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if ((p = xdr_decode_string_inplace(p, namp, lenp, NFS3_MAXNAMLEN)) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) for (i = 0, name = *namp; i < *lenp; i++, name++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) if (*name == '\0' || *name == '/')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return NULL;
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) decode_sattr3(__be32 *p, struct iattr *iap, struct user_namespace *userns)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) u32 tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) iap->ia_valid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) if (*p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) iap->ia_valid |= ATTR_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) iap->ia_mode = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (*p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) iap->ia_uid = make_kuid(userns, ntohl(*p++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) if (uid_valid(iap->ia_uid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) iap->ia_valid |= ATTR_UID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) if (*p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) iap->ia_gid = make_kgid(userns, ntohl(*p++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) if (gid_valid(iap->ia_gid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) iap->ia_valid |= ATTR_GID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (*p++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) u64 newsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) iap->ia_valid |= ATTR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) p = xdr_decode_hyper(p, &newsize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) iap->ia_size = min_t(u64, newsize, NFS_OFFSET_MAX);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if ((tmp = ntohl(*p++)) == 1) { /* set to server time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) iap->ia_valid |= ATTR_ATIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) } else if (tmp == 2) { /* set to client time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) iap->ia_valid |= ATTR_ATIME | ATTR_ATIME_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) iap->ia_atime.tv_sec = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) iap->ia_atime.tv_nsec = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) if ((tmp = ntohl(*p++)) == 1) { /* set to server time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) iap->ia_valid |= ATTR_MTIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) } else if (tmp == 2) { /* set to client time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) iap->ia_valid |= ATTR_MTIME | ATTR_MTIME_SET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) iap->ia_mtime.tv_sec = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) iap->ia_mtime.tv_nsec = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) static __be32 *encode_fsid(__be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) u64 f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) switch(fsid_source(fhp)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) case FSIDSOURCE_DEV:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) p = xdr_encode_hyper(p, (u64)huge_encode_dev
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) (fhp->fh_dentry->d_sb->s_dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) case FSIDSOURCE_FSID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) p = xdr_encode_hyper(p, (u64) fhp->fh_export->ex_fsid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) case FSIDSOURCE_UUID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) f = ((u64*)fhp->fh_export->ex_uuid)[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) f ^= ((u64*)fhp->fh_export->ex_uuid)[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) p = xdr_encode_hyper(p, f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) encode_fattr3(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) struct kstat *stat)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) struct user_namespace *userns = nfsd_user_namespace(rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) *p++ = htonl(nfs3_ftypes[(stat->mode & S_IFMT) >> 12]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) *p++ = htonl((u32) (stat->mode & S_IALLUGO));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) *p++ = htonl((u32) stat->nlink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) *p++ = htonl((u32) from_kuid_munged(userns, stat->uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) *p++ = htonl((u32) from_kgid_munged(userns, stat->gid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (S_ISLNK(stat->mode) && stat->size > NFS3_MAXPATHLEN) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) p = xdr_encode_hyper(p, (u64) NFS3_MAXPATHLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) p = xdr_encode_hyper(p, (u64) stat->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) p = xdr_encode_hyper(p, ((u64)stat->blocks) << 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) *p++ = htonl((u32) MAJOR(stat->rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) *p++ = htonl((u32) MINOR(stat->rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) p = encode_fsid(p, fhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) p = xdr_encode_hyper(p, stat->ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) p = encode_time3(p, &stat->atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) p = encode_time3(p, &stat->mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) p = encode_time3(p, &stat->ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) encode_saved_post_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) /* Attributes to follow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return encode_fattr3(rqstp, p, fhp, &fhp->fh_post_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Encode post-operation attributes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * The inode may be NULL if the call failed because of a stale file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * handle. In this case, no attributes are returned.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) struct dentry *dentry = fhp->fh_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (dentry && d_really_is_positive(dentry)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) __be32 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) err = fh_getattr(fhp, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) *p++ = xdr_one; /* attributes follow */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) lease_get_mtime(d_inode(dentry), &stat.mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return encode_fattr3(rqstp, p, fhp, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) /* Helper for NFSv3 ACLs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) nfs3svc_encode_post_op_attr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) return encode_post_op_attr(rqstp, p, fhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) * Enocde weak cache consistency data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) encode_wcc_data(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) struct dentry *dentry = fhp->fh_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (dentry && d_really_is_positive(dentry) && fhp->fh_post_saved) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) if (fhp->fh_pre_saved) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) p = xdr_encode_hyper(p, (u64) fhp->fh_pre_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) p = encode_time3(p, &fhp->fh_pre_mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) p = encode_time3(p, &fhp->fh_pre_ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return encode_saved_post_attr(rqstp, p, fhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) /* no pre- or post-attrs */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return encode_post_op_attr(rqstp, p, fhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) * Fill in the pre_op attr for the wcc data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) void fill_pre_wcc(struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) __be32 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (fhp->fh_pre_saved)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) inode = d_inode(fhp->fh_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) err = fh_getattr(fhp, &stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) /* Grab the times from inode anyway */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) stat.mtime = inode->i_mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) stat.ctime = inode->i_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) stat.size = inode->i_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) fhp->fh_pre_mtime = stat.mtime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) fhp->fh_pre_ctime = stat.ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) fhp->fh_pre_size = stat.size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) fhp->fh_pre_change = nfsd4_change_attribute(&stat, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) fhp->fh_pre_saved = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) * Fill in the post_op attr for the wcc data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) void fill_post_wcc(struct svc_fh *fhp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) __be32 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) if (fhp->fh_post_saved)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) printk("nfsd: inode locked twice during operation.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) err = fh_getattr(fhp, &fhp->fh_post_attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) fhp->fh_post_change = nfsd4_change_attribute(&fhp->fh_post_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) d_inode(fhp->fh_dentry));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) fhp->fh_post_saved = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) /* Grab the ctime anyway - set_change_info might use it */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) fhp->fh_post_attr.ctime = d_inode(fhp->fh_dentry)->i_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) fhp->fh_post_saved = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) * XDR decode functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) nfs3svc_decode_voidarg(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) nfs3svc_decode_fhandle(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) struct nfsd_fhandle *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) return xdr_argsize_check(rqstp, p);
^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) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) nfs3svc_decode_sattrargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) struct nfsd3_sattrargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if ((args->check_guard = ntohl(*p++)) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) struct timespec64 time;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) p = decode_time3(p, &time);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) args->guardtime = time.tv_sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) nfs3svc_decode_diropargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) struct nfsd3_diropargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if (!(p = decode_fh(p, &args->fh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) || !(p = decode_filename(p, &args->name, &args->len)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) nfs3svc_decode_accessargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) struct nfsd3_accessargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) args->access = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) nfs3svc_decode_readargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) struct nfsd3_readargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) int v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) u32 max_blocksize = svc_max_payload(rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) p = xdr_decode_hyper(p, &args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) args->count = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) len = min(args->count, max_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) /* set up the kvec */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) v=0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) while (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) struct page *p = *(rqstp->rq_next_page++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) rqstp->rq_vec[v].iov_base = page_address(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) rqstp->rq_vec[v].iov_len = min_t(unsigned int, len, PAGE_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) len -= rqstp->rq_vec[v].iov_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) v++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) args->vlen = v;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) nfs3svc_decode_writeargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) struct nfsd3_writeargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) unsigned int len, hdr, dlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) u32 max_blocksize = svc_max_payload(rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct kvec *head = rqstp->rq_arg.head;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) struct kvec *tail = rqstp->rq_arg.tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) p = xdr_decode_hyper(p, &args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) args->count = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) args->stable = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) len = args->len = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) if ((void *)p > head->iov_base + head->iov_len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) * The count must equal the amount of data passed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) if (args->count != args->len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) * Check to make sure that we got the right number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) * bytes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) hdr = (void*)p - head->iov_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) dlen = head->iov_len + rqstp->rq_arg.page_len + tail->iov_len - hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) * Round the length of the data which was specified up to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) * the next multiple of XDR units and then compare that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) * against the length which was actually received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) * Note that when RPCSEC/GSS (for example) is used, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) * data buffer can be padded so dlen might be larger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) * than required. It must never be smaller.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) if (dlen < XDR_QUADLEN(len)*4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) if (args->count > max_blocksize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) args->count = max_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) len = args->len = max_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) args->first.iov_base = (void *)p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) args->first.iov_len = head->iov_len - hdr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) nfs3svc_decode_createargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) struct nfsd3_createargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) if (!(p = decode_fh(p, &args->fh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) || !(p = decode_filename(p, &args->name, &args->len)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) switch (args->createmode = ntohl(*p++)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) case NFS3_CREATE_UNCHECKED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) case NFS3_CREATE_GUARDED:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) case NFS3_CREATE_EXCLUSIVE:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) args->verf = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) p += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) return xdr_argsize_check(rqstp, p);
^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) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) nfs3svc_decode_mkdirargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) struct nfsd3_createargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if (!(p = decode_fh(p, &args->fh)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) !(p = decode_filename(p, &args->name, &args->len)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) nfs3svc_decode_symlinkargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) struct nfsd3_symlinkargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) char *base = (char *)p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) size_t dlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) if (!(p = decode_fh(p, &args->ffh)) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) !(p = decode_filename(p, &args->fname, &args->flen)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) args->tlen = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) args->first.iov_base = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) args->first.iov_len = rqstp->rq_arg.head[0].iov_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) args->first.iov_len -= (char *)p - base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) dlen = args->first.iov_len + rqstp->rq_arg.page_len +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) rqstp->rq_arg.tail[0].iov_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) if (dlen < XDR_QUADLEN(args->tlen) << 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) nfs3svc_decode_mknodargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) struct nfsd3_mknodargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) if (!(p = decode_fh(p, &args->fh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) || !(p = decode_filename(p, &args->name, &args->len)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) args->ftype = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) if (args->ftype == NF3BLK || args->ftype == NF3CHR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) || args->ftype == NF3SOCK || args->ftype == NF3FIFO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) p = decode_sattr3(p, &args->attrs, nfsd_user_namespace(rqstp));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) if (args->ftype == NF3BLK || args->ftype == NF3CHR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) args->major = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) args->minor = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) nfs3svc_decode_renameargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) struct nfsd3_renameargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) if (!(p = decode_fh(p, &args->ffh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) || !(p = decode_filename(p, &args->fname, &args->flen))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) || !(p = decode_fh(p, &args->tfh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) || !(p = decode_filename(p, &args->tname, &args->tlen)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) nfs3svc_decode_readlinkargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) struct nfsd3_readlinkargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) args->buffer = page_address(*(rqstp->rq_next_page++));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) nfs3svc_decode_linkargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) struct nfsd3_linkargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) if (!(p = decode_fh(p, &args->ffh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) || !(p = decode_fh(p, &args->tfh))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) || !(p = decode_filename(p, &args->tname, &args->tlen)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) nfs3svc_decode_readdirargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) struct nfsd3_readdirargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) u32 max_blocksize = svc_max_payload(rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) p = xdr_decode_hyper(p, &args->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) args->verf = p; p += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) args->dircount = ~0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) args->count = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) len = args->count = min_t(u32, args->count, max_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) while (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) struct page *p = *(rqstp->rq_next_page++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) if (!args->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) args->buffer = page_address(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) len -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) return xdr_argsize_check(rqstp, p);
^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) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) nfs3svc_decode_readdirplusargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) struct nfsd3_readdirargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) u32 max_blocksize = svc_max_payload(rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) p = xdr_decode_hyper(p, &args->cookie);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) args->verf = p; p += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) args->dircount = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) args->count = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) len = args->count = min(args->count, max_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) while (len > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) struct page *p = *(rqstp->rq_next_page++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) if (!args->buffer)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) args->buffer = page_address(p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) len -= PAGE_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) nfs3svc_decode_commitargs(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) struct nfsd3_commitargs *args = rqstp->rq_argp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) p = decode_fh(p, &args->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) if (!p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) p = xdr_decode_hyper(p, &args->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) args->count = ntohl(*p++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) return xdr_argsize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) * XDR encode functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) nfs3svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) /* GETATTR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) nfs3svc_encode_attrstat(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) struct nfsd3_attrstat *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) lease_get_mtime(d_inode(resp->fh.fh_dentry),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) &resp->stat.mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) p = encode_fattr3(rqstp, p, &resp->fh, &resp->stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663) return xdr_ressize_check(rqstp, p);
^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) /* SETATTR, REMOVE, RMDIR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668) nfs3svc_encode_wccstat(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) struct nfsd3_attrstat *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673) p = encode_wcc_data(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) /* LOOKUP */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) nfs3svc_encode_diropres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) struct nfsd3_diropres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) p = encode_fh(p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688) p = encode_post_op_attr(rqstp, p, &resp->dirfh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) /* ACCESS */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) nfs3svc_encode_accessres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) struct nfsd3_accessres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) if (resp->status == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) *p++ = htonl(resp->access);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) /* READLINK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) nfs3svc_encode_readlinkres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709) struct nfsd3_readlinkres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) *p++ = htonl(resp->len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715) xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) rqstp->rq_res.page_len = resp->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) if (resp->len & 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) /* need to pad the tail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) rqstp->rq_res.tail[0].iov_base = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) *p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) rqstp->rq_res.tail[0].iov_len = 4 - (resp->len&3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) /* READ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) nfs3svc_encode_readres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) struct nfsd3_readres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) *p++ = htonl(resp->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) *p++ = htonl(resp->eof);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) *p++ = htonl(resp->count); /* xdr opaque count */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) /* now update rqstp->rq_res to reflect data as well */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) rqstp->rq_res.page_len = resp->count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743) if (resp->count & 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) /* need to pad the tail */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) rqstp->rq_res.tail[0].iov_base = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) *p = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) rqstp->rq_res.tail[0].iov_len = 4 - (resp->count & 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) /* WRITE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756) nfs3svc_encode_writeres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) struct nfsd3_writeres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) p = encode_wcc_data(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) *p++ = htonl(resp->count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764) *p++ = htonl(resp->committed);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) *p++ = resp->verf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) *p++ = resp->verf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) /* CREATE, MKDIR, SYMLINK, MKNOD */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) nfs3svc_encode_createres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) struct nfsd3_diropres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) p = encode_fh(p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) p = encode_wcc_data(rqstp, p, &resp->dirfh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784) return xdr_ressize_check(rqstp, p);
^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) /* RENAME */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789) nfs3svc_encode_renameres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) struct nfsd3_renameres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) p = encode_wcc_data(rqstp, p, &resp->ffh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) p = encode_wcc_data(rqstp, p, &resp->tfh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) /* LINK */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) nfs3svc_encode_linkres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) struct nfsd3_linkres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807) p = encode_wcc_data(rqstp, p, &resp->tfh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) /* READDIR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) nfs3svc_encode_readdirres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) struct nfsd3_readdirres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) p = encode_post_op_attr(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) /* stupid readdir cookie */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822) memcpy(p, resp->verf, 8); p += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) if (rqstp->rq_res.head[0].iov_len + (2<<2) > PAGE_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) return 1; /*No room for trailer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) rqstp->rq_res.page_len = (resp->count) << 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) /* add the 'tail' to the end of the 'head' page - page 0. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) rqstp->rq_res.tail[0].iov_base = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830) *p++ = 0; /* no more entries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) *p++ = htonl(resp->common.err == nfserr_eof);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) rqstp->rq_res.tail[0].iov_len = 2<<2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) static __be32 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) encode_entry_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840) int namlen, u64 ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) *p++ = xdr_one; /* mark entry present */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) p = xdr_encode_hyper(p, ino); /* file id */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) p = xdr_encode_array(p, name, namlen);/* name length & name */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) cd->offset = p; /* remember pointer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) p = xdr_encode_hyper(p, NFS_OFFSET_MAX);/* offset of next entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) static __be32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) compose_entry_fh(struct nfsd3_readdirres *cd, struct svc_fh *fhp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) const char *name, int namlen, u64 ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) struct svc_export *exp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) struct dentry *dparent, *dchild;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) __be32 rv = nfserr_noent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860) dparent = cd->fh.fh_dentry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) exp = cd->fh.fh_export;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) if (isdotent(name, namlen)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) if (namlen == 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865) dchild = dget_parent(dparent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) * Don't return filehandle for ".." if we're at
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) * the filesystem or export root:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870) if (dchild == dparent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) if (dparent == exp->ex_path.dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875) dchild = dget(dparent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) dchild = lookup_positive_unlocked(name, dparent, namlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) if (IS_ERR(dchild))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) return rv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880) if (d_mountpoint(dchild))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) if (dchild->d_inode->i_ino != ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) rv = fh_compose(fhp, exp, dchild, &cd->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) dput(dchild);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) return rv;
^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 __be32 *encode_entryplus_baggage(struct nfsd3_readdirres *cd, __be32 *p, const char *name, int namlen, u64 ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892) struct svc_fh *fh = &cd->scratch;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) __be32 err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) fh_init(fh, NFS3_FHSIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) err = compose_entry_fh(cd, fh, name, namlen, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) *p++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) *p++ = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) p = encode_post_op_attr(cd->rqstp, p, fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) *p++ = xdr_one; /* yes, a file handle follows */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) p = encode_fh(p, fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) fh_put(fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) return p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) * Encode a directory entry. This one works for both normal readdir
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) * and readdirplus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) * The normal readdir reply requires 2 (fileid) + 1 (stringlen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) * + string + 2 (cookie) + 1 (next) words, i.e. 6 + strlen.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) * The readdirplus baggage is 1+21 words for post_op_attr, plus the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) * file handle.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920) #define NFS3_ENTRY_BAGGAGE (2 + 1 + 2 + 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) #define NFS3_ENTRYPLUS_BAGGAGE (1 + 21 + 1 + (NFS3_FHSIZE >> 2))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) encode_entry(struct readdir_cd *ccd, const char *name, int namlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) loff_t offset, u64 ino, unsigned int d_type, int plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) struct nfsd3_readdirres *cd = container_of(ccd, struct nfsd3_readdirres,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) common);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) __be32 *p = cd->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) caddr_t curr_page_addr = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930) struct page ** page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) int slen; /* string (name) length */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) int elen; /* estimated entry length in words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) int num_entry_words = 0; /* actual number of words */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935) if (cd->offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) u64 offset64 = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) if (unlikely(cd->offset1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) /* we ended up with offset on a page boundary */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940) *cd->offset = htonl(offset64 >> 32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) *cd->offset1 = htonl(offset64 & 0xffffffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) cd->offset1 = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) xdr_encode_hyper(cd->offset, offset64);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) cd->offset = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950) dprintk("encode_entry(%.*s @%ld%s)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) namlen, name, (long) offset, plus? " plus" : "");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) /* truncate filename if too long */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955) namlen = min(namlen, NFS3_MAXNAMLEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) slen = XDR_QUADLEN(namlen);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) elen = slen + NFS3_ENTRY_BAGGAGE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) + (plus? NFS3_ENTRYPLUS_BAGGAGE : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) if (cd->buflen < elen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) cd->common.err = nfserr_toosmall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) /* determine which page in rq_respages[] we are currently filling */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) for (page = cd->rqstp->rq_respages + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) page < cd->rqstp->rq_next_page; page++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) curr_page_addr = page_address(*page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) if (((caddr_t)cd->buffer >= curr_page_addr) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) ((caddr_t)cd->buffer < curr_page_addr + PAGE_SIZE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) if ((caddr_t)(cd->buffer + elen) < (curr_page_addr + PAGE_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977) /* encode entry in current page */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) p = encode_entry_baggage(cd, p, name, namlen, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) if (plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982) p = encode_entryplus_baggage(cd, p, name, namlen, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) num_entry_words = p - cd->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) } else if (*(page+1) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) /* temporarily encode entry into next page, then move back to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) * current and next page in rq_respages[] */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987) __be32 *p1, *tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) int len1, len2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) /* grab next page for temporary storage of entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) p1 = tmp = page_address(*(page+1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) p1 = encode_entry_baggage(cd, p1, name, namlen, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) if (plus)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) p1 = encode_entryplus_baggage(cd, p1, name, namlen, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) /* determine entry word length and lengths to go in pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) num_entry_words = p1 - tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) len1 = curr_page_addr + PAGE_SIZE - (caddr_t)cd->buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) if ((num_entry_words << 2) < len1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) /* the actual number of words in the entry is less
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) * than elen and can still fit in the current page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) memmove(p, tmp, num_entry_words << 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) p += num_entry_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) /* update offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) cd->offset = cd->buffer + (cd->offset - tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) unsigned int offset_r = (cd->offset - tmp) << 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) /* update pointer to offset location.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) * This is a 64bit quantity, so we need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) * deal with 3 cases:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) * - entirely in first page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) * - entirely in second page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) * - 4 bytes in each page
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) if (offset_r + 8 <= len1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) cd->offset = p + (cd->offset - tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) } else if (offset_r >= len1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) cd->offset -= len1 >> 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) /* sitting on the fence */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) BUG_ON(offset_r != len1 - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) cd->offset = p + (cd->offset - tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) cd->offset1 = tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) len2 = (num_entry_words << 2) - len1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) /* move from temp page to current and next pages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) memmove(p, tmp, len1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) memmove(tmp, (caddr_t)tmp+len1, len2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) p = tmp + (len2 >> 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) cd->common.err = nfserr_toosmall;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) cd->buflen -= num_entry_words;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) cd->buffer = p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) cd->common.err = nfs_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) return 0;
^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)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) nfs3svc_encode_entry(void *cd, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) int namlen, loff_t offset, u64 ino, unsigned int d_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) return encode_entry(cd, name, namlen, offset, ino, d_type, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) nfs3svc_encode_entry_plus(void *cd, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) int namlen, loff_t offset, u64 ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) unsigned int d_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) return encode_entry(cd, name, namlen, offset, ino, d_type, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) /* FSSTAT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) nfs3svc_encode_fsstatres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) struct nfsd3_fsstatres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) struct kstatfs *s = &resp->stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) u64 bs = s->f_bsize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) *p++ = xdr_zero; /* no post_op_attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) p = xdr_encode_hyper(p, bs * s->f_blocks); /* total bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) p = xdr_encode_hyper(p, bs * s->f_bfree); /* free bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) p = xdr_encode_hyper(p, bs * s->f_bavail); /* user available bytes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) p = xdr_encode_hyper(p, s->f_files); /* total inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) p = xdr_encode_hyper(p, s->f_ffree); /* free inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) p = xdr_encode_hyper(p, s->f_ffree); /* user available inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) *p++ = htonl(resp->invarsec); /* mean unchanged time */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) /* FSINFO */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) struct nfsd3_fsinfores *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) *p++ = xdr_zero; /* no post_op_attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) *p++ = htonl(resp->f_rtmax);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) *p++ = htonl(resp->f_rtpref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) *p++ = htonl(resp->f_rtmult);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) *p++ = htonl(resp->f_wtmax);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) *p++ = htonl(resp->f_wtpref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) *p++ = htonl(resp->f_wtmult);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) *p++ = htonl(resp->f_dtpref);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) p = xdr_encode_hyper(p, resp->f_maxfilesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) *p++ = xdr_one;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) *p++ = xdr_zero;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) *p++ = htonl(resp->f_properties);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) /* PATHCONF */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) struct nfsd3_pathconfres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) *p++ = xdr_zero; /* no post_op_attr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) *p++ = htonl(resp->p_link_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) *p++ = htonl(resp->p_name_max);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) *p++ = htonl(resp->p_no_trunc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) *p++ = htonl(resp->p_chown_restricted);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) *p++ = htonl(resp->p_case_insensitive);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) *p++ = htonl(resp->p_case_preserving);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) /* COMMIT */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) nfs3svc_encode_commitres(struct svc_rqst *rqstp, __be32 *p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) struct nfsd3_commitres *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) *p++ = resp->status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) p = encode_wcc_data(rqstp, p, &resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) /* Write verifier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) if (resp->status == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) *p++ = resp->verf[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) *p++ = resp->verf[1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) return xdr_ressize_check(rqstp, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) * XDR release functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) nfs3svc_release_fhandle(struct svc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) struct nfsd3_attrstat *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) fh_put(&resp->fh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) nfs3svc_release_fhandle2(struct svc_rqst *rqstp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) struct nfsd3_fhandle_pair *resp = rqstp->rq_resp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) fh_put(&resp->fh1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) fh_put(&resp->fh2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) }