^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) /* XDR types for nfsd. This is mainly a typing exercise. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #ifndef LINUX_NFSD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #define LINUX_NFSD_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/vfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "nfsd.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "nfsfh.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) struct nfsd_fhandle {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct nfsd_sattrargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) struct iattr attrs;
^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) struct nfsd_diropargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) char * name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) struct nfsd_readargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int vlen;
^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) struct nfsd_writeargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) __u32 offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) __u32 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) struct kvec first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct nfsd_createargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) char * name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) unsigned int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct iattr attrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) struct nfsd_renameargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) struct svc_fh ffh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) char * fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) unsigned int flen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct svc_fh tfh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) char * tname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) unsigned int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct nfsd_readlinkargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) char * buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct nfsd_linkargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct svc_fh ffh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) struct svc_fh tfh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) char * tname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) unsigned int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) struct nfsd_symlinkargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) struct svc_fh ffh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) char * fname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) unsigned int flen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) char * tname;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned int tlen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct iattr attrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) struct kvec first;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) struct nfsd_readdirargs {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) __u32 cookie;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) __u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) __be32 * buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) struct nfsd_stat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) struct nfsd_attrstat {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) struct kstat 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) struct nfsd_diropres {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct nfsd_readlinkres {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct nfsd_readres {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct svc_fh fh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) unsigned long count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct kstat stat;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) struct nfsd_readdirres {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) int count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) struct readdir_cd common;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) __be32 * buffer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) int buflen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) __be32 * offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) struct nfsd_statfsres {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) __be32 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) struct kstatfs stats;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) * Storage requirements for XDR arguments and results.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) union nfsd_xdrstore {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) struct nfsd_sattrargs sattr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) struct nfsd_diropargs dirop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) struct nfsd_readargs read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) struct nfsd_writeargs write;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) struct nfsd_createargs create;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) struct nfsd_renameargs rename;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) struct nfsd_linkargs link;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) struct nfsd_symlinkargs symlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) struct nfsd_readdirargs readdir;
^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) #define NFS2_SVC_XDRSIZE sizeof(union nfsd_xdrstore)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) int nfssvc_decode_void(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) int nfssvc_decode_fhandle(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) int nfssvc_decode_sattrargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int nfssvc_decode_diropargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) int nfssvc_decode_readargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) int nfssvc_decode_writeargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) int nfssvc_decode_createargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) int nfssvc_decode_renameargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) int nfssvc_decode_readlinkargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) int nfssvc_decode_linkargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int nfssvc_decode_symlinkargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) int nfssvc_decode_readdirargs(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) int nfssvc_encode_void(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) int nfssvc_encode_stat(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) int nfssvc_encode_attrstat(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int nfssvc_encode_diropres(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) int nfssvc_encode_readlinkres(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) int nfssvc_encode_readres(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int nfssvc_encode_statfsres(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int nfssvc_encode_readdirres(struct svc_rqst *, __be32 *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int nfssvc_encode_entry(void *, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) int namlen, loff_t offset, u64 ino, unsigned int);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) void nfssvc_release_attrstat(struct svc_rqst *rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) void nfssvc_release_diropres(struct svc_rqst *rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) void nfssvc_release_readres(struct svc_rqst *rqstp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) /* Helper functions for NFSv2 ACL code */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) __be32 *nfs2svc_encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, struct kstat *stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) __be32 *nfs2svc_decode_fh(__be32 *p, struct svc_fh *fhp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) #endif /* LINUX_NFSD_H */