// SPDX-License-Identifier: GPL-2.0
// Generated by xdrgen. Manual edits will be lost.
// XDR specification file: ../../Documentation/sunrpc/xdr/nfs2.x
// XDR specification modification time: Tue Sep  8 11:26:28 2026

#include <linux/sunrpc/svc.h>

#include "nfs2xdr_gen.h"

static bool __maybe_unused
xdrgen_decode_nfsstat(struct xdr_stream *xdr, nfsstat *ptr)
{
	__be32 raw;
	u32 val;

	if (xdr_stream_decode_be32(xdr, &raw) < 0)
		return false;
	val = be32_to_cpu(raw);
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case NFS_OK:
	case NFSERR_PERM:
	case NFSERR_NOENT:
	case NFSERR_IO:
	case NFSERR_NXIO:
	case NFSERR_ACCES:
	case NFSERR_EXIST:
	case NFSERR_NODEV:
	case NFSERR_NOTDIR:
	case NFSERR_ISDIR:
	case NFSERR_FBIG:
	case NFSERR_NOSPC:
	case NFSERR_ROFS:
	case NFSERR_NAMETOOLONG:
	case NFSERR_NOTEMPTY:
	case NFSERR_DQUOT:
	case NFSERR_STALE:
	case NFSERR_WFLUSH:
		break;
	default:
		return false;
	}
	*ptr = raw;
	return true;
}

static bool __maybe_unused
xdrgen_decode_ftype(struct xdr_stream *xdr, ftype *ptr)
{
	u32 val;

	if (xdr_stream_decode_u32(xdr, &val) < 0)
		return false;
	/* Compiler may optimize to a range check for dense enums */
	switch (val) {
	case NFNON:
	case NFREG:
	case NFDIR:
	case NFBLK:
	case NFCHR:
	case NFLNK:
		break;
	default:
		return false;
	}
	*ptr = val;
	return true;
}

static bool __maybe_unused
xdrgen_decode_fhandle(struct xdr_stream *xdr, fhandle *ptr)
{
	return xdr_stream_decode_opaque_fixed(xdr, ptr, NFS_FHSIZE) == 0;
}

static bool __maybe_unused
xdrgen_decode_nfscookie(struct xdr_stream *xdr, nfscookie *ptr)
{
	return xdr_stream_decode_opaque_fixed(xdr, ptr, NFS_COOKIESIZE) == 0;
}

static bool __maybe_unused
xdrgen_decode_timeval(struct xdr_stream *xdr, struct timeval *ptr)
{
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->seconds))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->useconds))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_fattr(struct xdr_stream *xdr, struct fattr *ptr)
{
	if (!xdrgen_decode_ftype(xdr, &ptr->type))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->mode))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->nlink))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->uid))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->gid))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->size))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->blocksize))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->rdev))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->blocks))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->fsid))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->fileid))
		return false;
	if (!xdrgen_decode_timeval(xdr, &ptr->atime))
		return false;
	if (!xdrgen_decode_timeval(xdr, &ptr->mtime))
		return false;
	if (!xdrgen_decode_timeval(xdr, &ptr->ctime))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_sattr(struct xdr_stream *xdr, struct sattr *ptr)
{
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->mode))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->uid))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->gid))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->size))
		return false;
	if (!xdrgen_decode_timeval(xdr, &ptr->atime))
		return false;
	if (!xdrgen_decode_timeval(xdr, &ptr->mtime))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_filename(struct xdr_stream *xdr, filename *ptr)
{
	return xdrgen_decode_string(xdr, ptr, NFS_MAXNAMLEN);
}

static bool __maybe_unused
xdrgen_decode_path(struct xdr_stream *xdr, path *ptr)
{
	return xdrgen_decode_string(xdr, ptr, NFS_MAXPATHLEN);
}

static bool __maybe_unused
xdrgen_decode_attrstat(struct xdr_stream *xdr, struct attrstat *ptr)
{
	if (!xdrgen_decode_nfsstat(xdr, &ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_decode_fattr(xdr, &ptr->u.attributes))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_decode_diropargs(struct xdr_stream *xdr, struct diropargs *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->dir))
		return false;
	if (!xdrgen_decode_filename(xdr, &ptr->name))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_diropok(struct xdr_stream *xdr, struct diropok *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->file))
		return false;
	if (!xdrgen_decode_fattr(xdr, &ptr->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_diropres(struct xdr_stream *xdr, struct diropres *ptr)
{
	if (!xdrgen_decode_nfsstat(xdr, &ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_decode_diropok(xdr, &ptr->u.diropok))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_decode_sattrargs(struct xdr_stream *xdr, struct sattrargs *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->file))
		return false;
	if (!xdrgen_decode_sattr(xdr, &ptr->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_readlinkres(struct xdr_stream *xdr, struct readlinkres *ptr)
{
	if (!xdrgen_decode_nfsstat(xdr, &ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_decode_path(xdr, &ptr->u.data))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_decode_readargs(struct xdr_stream *xdr, struct readargs *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->file))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->offset))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->count))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->totalcount))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_readresok(struct xdr_stream *xdr, struct readresok *ptr)
{
	if (!xdrgen_decode_fattr(xdr, &ptr->attributes))
		return false;
	if (!xdrgen_decode_opaque(xdr, &ptr->data, NFS_MAXDATA))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_readres(struct xdr_stream *xdr, struct readres *ptr)
{
	if (!xdrgen_decode_nfsstat(xdr, &ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_decode_readresok(xdr, &ptr->u.readresok))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_decode_writeargs(struct xdr_stream *xdr, struct writeargs *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->file))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->beginoffset))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->offset))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->totalcount))
		return false;
	if (!svcxdr_decode_opaque_payload(xdr, &ptr->data, NFS_MAXDATA))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_createargs(struct xdr_stream *xdr, struct createargs *ptr)
{
	if (!xdrgen_decode_diropargs(xdr, &ptr->where))
		return false;
	if (!xdrgen_decode_sattr(xdr, &ptr->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_renameargs(struct xdr_stream *xdr, struct renameargs *ptr)
{
	if (!xdrgen_decode_diropargs(xdr, &ptr->from))
		return false;
	if (!xdrgen_decode_diropargs(xdr, &ptr->to))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_linkargs(struct xdr_stream *xdr, struct linkargs *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->from))
		return false;
	if (!xdrgen_decode_diropargs(xdr, &ptr->to))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_symlinkargs(struct xdr_stream *xdr, struct symlinkargs *ptr)
{
	if (!xdrgen_decode_diropargs(xdr, &ptr->from))
		return false;
	if (!svcxdr_decode_opaque_payload(xdr, &ptr->to, NFS_MAXPATHLEN))
		return false;
	if (!xdrgen_decode_sattr(xdr, &ptr->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_readdirargs(struct xdr_stream *xdr, struct readdirargs *ptr)
{
	if (!xdrgen_decode_fhandle(xdr, &ptr->dir))
		return false;
	if (!xdrgen_decode_nfscookie(xdr, &ptr->cookie))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->count))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_entry(struct xdr_stream *xdr, struct entry *ptr)
{
	bool opted;

	if (!xdrgen_decode_bool(xdr, &opted))
		return false;
	if (!opted)
		return true;

	if (!xdrgen_decode_unsigned_int(xdr, &ptr->fileid))
		return false;
	if (!xdrgen_decode_filename(xdr, &ptr->name))
		return false;
	if (!xdrgen_decode_nfscookie(xdr, &ptr->cookie))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_readdirok(struct xdr_stream *xdr, struct readdirok *ptr)
{
	return false;
}

static bool __maybe_unused
xdrgen_decode_readdirres(struct xdr_stream *xdr, struct readdirres *ptr)
{
	if (!xdrgen_decode_nfsstat(xdr, &ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_decode_readdirok(xdr, &ptr->u.readdirok))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_decode_info(struct xdr_stream *xdr, struct info *ptr)
{
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->tsize))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->bsize))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->blocks))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->bfree))
		return false;
	if (!xdrgen_decode_unsigned_int(xdr, &ptr->bavail))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_decode_statfsres(struct xdr_stream *xdr, struct statfsres *ptr)
{
	if (!xdrgen_decode_nfsstat(xdr, &ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_decode_info(xdr, &ptr->u.info))
			return false;
		break;
	default:
		break;
	}
	return true;
}

/**
 * nfs_svc_decode_fhandle - Decode a fhandle argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_fhandle(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	fhandle *argp = rqstp->rq_argp;

	return xdrgen_decode_fhandle(xdr, argp);
}

/**
 * nfs_svc_decode_sattrargs - Decode a sattrargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_sattrargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct sattrargs *argp = rqstp->rq_argp;

	return xdrgen_decode_sattrargs(xdr, argp);
}

/**
 * nfs_svc_decode_diropargs - Decode a diropargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_diropargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct diropargs *argp = rqstp->rq_argp;

	return xdrgen_decode_diropargs(xdr, argp);
}

/**
 * nfs_svc_decode_readargs - Decode a readargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_readargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct readargs *argp = rqstp->rq_argp;

	return xdrgen_decode_readargs(xdr, argp);
}

/**
 * nfs_svc_decode_writeargs - Decode a writeargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_writeargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct writeargs *argp = rqstp->rq_argp;

	return xdrgen_decode_writeargs(xdr, argp);
}

/**
 * nfs_svc_decode_createargs - Decode a createargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_createargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct createargs *argp = rqstp->rq_argp;

	return xdrgen_decode_createargs(xdr, argp);
}

/**
 * nfs_svc_decode_renameargs - Decode a renameargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_renameargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct renameargs *argp = rqstp->rq_argp;

	return xdrgen_decode_renameargs(xdr, argp);
}

/**
 * nfs_svc_decode_linkargs - Decode a linkargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_linkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct linkargs *argp = rqstp->rq_argp;

	return xdrgen_decode_linkargs(xdr, argp);
}

/**
 * nfs_svc_decode_symlinkargs - Decode a symlinkargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_symlinkargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct symlinkargs *argp = rqstp->rq_argp;

	return xdrgen_decode_symlinkargs(xdr, argp);
}

/**
 * nfs_svc_decode_readdirargs - Decode a readdirargs argument
 * @rqstp: RPC transaction context
 * @xdr: source XDR data stream
 *
 * Return values:
 *   %true: procedure arguments decoded successfully
 *   %false: decode failed
 */
bool nfs_svc_decode_readdirargs(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct readdirargs *argp = rqstp->rq_argp;

	return xdrgen_decode_readdirargs(xdr, argp);
}

static bool __maybe_unused
xdrgen_encode_nfsstat(struct xdr_stream *xdr, nfsstat value)
{
	return xdr_stream_encode_be32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_ftype(struct xdr_stream *xdr, ftype value)
{
	return xdr_stream_encode_u32(xdr, value) == XDR_UNIT;
}

static bool __maybe_unused
xdrgen_encode_fhandle(struct xdr_stream *xdr, const fhandle value)
{
	return xdr_stream_encode_opaque_fixed(xdr, value, NFS_FHSIZE) >= 0;
}

static bool __maybe_unused
xdrgen_encode_nfscookie(struct xdr_stream *xdr, const nfscookie value)
{
	return xdr_stream_encode_opaque_fixed(xdr, value, NFS_COOKIESIZE) >= 0;
}

static bool __maybe_unused
xdrgen_encode_timeval(struct xdr_stream *xdr, const struct timeval *value)
{
	if (!xdrgen_encode_unsigned_int(xdr, value->seconds))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->useconds))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_fattr(struct xdr_stream *xdr, const struct fattr *value)
{
	if (!xdrgen_encode_ftype(xdr, value->type))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->mode))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->nlink))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->uid))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->gid))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->size))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->blocksize))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->rdev))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->blocks))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->fsid))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->fileid))
		return false;
	if (!xdrgen_encode_timeval(xdr, &value->atime))
		return false;
	if (!xdrgen_encode_timeval(xdr, &value->mtime))
		return false;
	if (!xdrgen_encode_timeval(xdr, &value->ctime))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_sattr(struct xdr_stream *xdr, const struct sattr *value)
{
	if (!xdrgen_encode_unsigned_int(xdr, value->mode))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->uid))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->gid))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->size))
		return false;
	if (!xdrgen_encode_timeval(xdr, &value->atime))
		return false;
	if (!xdrgen_encode_timeval(xdr, &value->mtime))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_filename(struct xdr_stream *xdr, const filename value)
{
	return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0;
}

static bool __maybe_unused
xdrgen_encode_path(struct xdr_stream *xdr, const path value)
{
	return xdr_stream_encode_opaque(xdr, value.data, value.len) >= 0;
}

static bool __maybe_unused
xdrgen_encode_attrstat(struct xdr_stream *xdr, const struct attrstat *ptr)
{
	if (!xdrgen_encode_nfsstat(xdr, ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_encode_fattr(xdr, &ptr->u.attributes))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_encode_diropargs(struct xdr_stream *xdr, const struct diropargs *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->dir))
		return false;
	if (!xdrgen_encode_filename(xdr, value->name))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_diropok(struct xdr_stream *xdr, const struct diropok *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->file))
		return false;
	if (!xdrgen_encode_fattr(xdr, &value->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_diropres(struct xdr_stream *xdr, const struct diropres *ptr)
{
	if (!xdrgen_encode_nfsstat(xdr, ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_encode_diropok(xdr, &ptr->u.diropok))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_encode_sattrargs(struct xdr_stream *xdr, const struct sattrargs *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->file))
		return false;
	if (!xdrgen_encode_sattr(xdr, &value->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_readlinkres(struct xdr_stream *xdr, const struct readlinkres *ptr)
{
	if (!xdrgen_encode_nfsstat(xdr, ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (ptr->u.data.len > NFS_MAXPATHLEN)
			return false;
		if (!svcxdr_encode_opaque_payload(xdr, ptr->u.data.len))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_encode_readargs(struct xdr_stream *xdr, const struct readargs *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->file))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->offset))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->count))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->totalcount))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_readresok(struct xdr_stream *xdr, const struct readresok *value)
{
	if (!xdrgen_encode_fattr(xdr, &value->attributes))
		return false;
	if (value->data.len > NFS_MAXDATA)
		return false;
	if (!svcxdr_encode_opaque_payload(xdr, value->data.len))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_readres(struct xdr_stream *xdr, const struct readres *ptr)
{
	if (!xdrgen_encode_nfsstat(xdr, ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_encode_readresok(xdr, &ptr->u.readresok))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_encode_writeargs(struct xdr_stream *xdr, const struct writeargs *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->file))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->beginoffset))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->offset))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->totalcount))
		return false;
	if (value->data.len > NFS_MAXDATA)
		return false;
	if (!svcxdr_encode_opaque_payload(xdr, value->data.len))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_createargs(struct xdr_stream *xdr, const struct createargs *value)
{
	if (!xdrgen_encode_diropargs(xdr, &value->where))
		return false;
	if (!xdrgen_encode_sattr(xdr, &value->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_renameargs(struct xdr_stream *xdr, const struct renameargs *value)
{
	if (!xdrgen_encode_diropargs(xdr, &value->from))
		return false;
	if (!xdrgen_encode_diropargs(xdr, &value->to))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_linkargs(struct xdr_stream *xdr, const struct linkargs *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->from))
		return false;
	if (!xdrgen_encode_diropargs(xdr, &value->to))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_symlinkargs(struct xdr_stream *xdr, const struct symlinkargs *value)
{
	if (!xdrgen_encode_diropargs(xdr, &value->from))
		return false;
	if (value->to.len > NFS_MAXPATHLEN)
		return false;
	if (!svcxdr_encode_opaque_payload(xdr, value->to.len))
		return false;
	if (!xdrgen_encode_sattr(xdr, &value->attributes))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_readdirargs(struct xdr_stream *xdr, const struct readdirargs *value)
{
	if (!xdrgen_encode_fhandle(xdr, value->dir))
		return false;
	if (!xdrgen_encode_nfscookie(xdr, value->cookie))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->count))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_entry(struct xdr_stream *xdr, const struct entry *value)
{
	if (!xdrgen_encode_bool(xdr, value != NULL))
		return false;
	if (!value)
		return true;

	if (!xdrgen_encode_unsigned_int(xdr, value->fileid))
		return false;
	if (!xdrgen_encode_filename(xdr, value->name))
		return false;
	if (!xdrgen_encode_nfscookie(xdr, value->cookie))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_readdirok(struct xdr_stream *xdr, const struct readdirok *value)
{
	{
		struct xdrgen_aggregate_cursor cursor = {
			.xdr = xdr,
			.member_id = NFS2_READDIROK_ENTRIES,
			.ctx = xdr->xdrgen_ctx,
		};
		bool ok = true;

		if (!nfs2_readdirok_encode_begin(&cursor))
			return false;
		for (cursor.index = 0; ; cursor.index++) {
			struct entry element = {};

			if (!nfs2_readdirok_encode(&cursor, &element))
				break;
			if (!xdrgen_encode_entry(xdr, &element)) {
				ok = false;
				break;
			}
		}
		if (ok && !xdrgen_encode_entry(xdr, NULL))
			ok = false;
		if (!nfs2_readdirok_encode_end(&cursor, ok) || !ok)
			return false;
	}
	if (!xdrgen_encode_bool(xdr, value->eof))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_readdirres(struct xdr_stream *xdr, const struct readdirres *ptr)
{
	if (!xdrgen_encode_nfsstat(xdr, ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_encode_readdirok(xdr, &ptr->u.readdirok))
			return false;
		break;
	default:
		break;
	}
	return true;
}

static bool __maybe_unused
xdrgen_encode_info(struct xdr_stream *xdr, const struct info *value)
{
	if (!xdrgen_encode_unsigned_int(xdr, value->tsize))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->bsize))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->blocks))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->bfree))
		return false;
	if (!xdrgen_encode_unsigned_int(xdr, value->bavail))
		return false;
	return true;
}

static bool __maybe_unused
xdrgen_encode_statfsres(struct xdr_stream *xdr, const struct statfsres *ptr)
{
	if (!xdrgen_encode_nfsstat(xdr, ptr->status))
		return false;
	switch (ptr->status) {
	case __constant_cpu_to_be32(NFS_OK):
		if (!xdrgen_encode_info(xdr, &ptr->u.info))
			return false;
		break;
	default:
		break;
	}
	return true;
}

/**
 * nfs_svc_encode_attrstat - Encode a attrstat result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_attrstat(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct attrstat *resp = rqstp->rq_resp;

	return xdrgen_encode_attrstat(xdr, resp);
}

/**
 * nfs_svc_encode_diropres - Encode a diropres result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_diropres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct diropres *resp = rqstp->rq_resp;

	return xdrgen_encode_diropres(xdr, resp);
}

/**
 * nfs_svc_encode_readlinkres - Encode a readlinkres result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_readlinkres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct readlinkres *resp = rqstp->rq_resp;

	return xdrgen_encode_readlinkres(xdr, resp);
}

/**
 * nfs_svc_encode_readres - Encode a readres result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_readres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct readres *resp = rqstp->rq_resp;

	return xdrgen_encode_readres(xdr, resp);
}

/**
 * nfs_svc_encode_nfsstat - Encode a nfsstat result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_nfsstat(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	nfsstat *resp = rqstp->rq_resp;

	return xdrgen_encode_nfsstat(xdr, *resp);
}

/**
 * nfs_svc_encode_readdirres - Encode a readdirres result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct readdirres *resp = rqstp->rq_resp;

	return xdrgen_encode_readdirres(xdr, resp);
}

/**
 * nfs_svc_encode_statfsres - Encode a statfsres result
 * @rqstp: RPC transaction context
 * @xdr: target XDR data stream
 *
 * Return values:
 *   %true: procedure results encoded successfully
 *   %false: encode failed
 */
bool nfs_svc_encode_statfsres(struct svc_rqst *rqstp, struct xdr_stream *xdr)
{
	struct statfsres *resp = rqstp->rq_resp;

	return xdrgen_encode_statfsres(xdr, resp);
}