fs/nfsd/nfs4xdr.c

Source file repositories/reference/linux-study-clean/fs/nfsd/nfs4xdr.c

File Facts

System
Linux kernel
Corpus path
fs/nfsd/nfs4xdr.c
Extension
.c
Size
177577 bytes
Lines
6490
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct nfsd4_fattr_args {
	struct svc_rqst		*rqstp;
	struct svc_fh		*fhp;
	struct svc_export	*exp;
	struct dentry		*dentry;
	struct kstat		stat;
	struct kstatfs		statfs;
	struct nfs4_acl		*acl;
	u64			change_attr;
#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
	struct lsm_context	context;
#endif
#ifdef CONFIG_NFSD_V4_POSIX_ACLS
	struct posix_acl	*dpacl;
	struct posix_acl	*pacl;
#endif
	u32			rdattr_err;
	bool			contextsupport;
	bool			ignore_crossmnt;
	bool			case_insensitive;
	bool			case_preserving;
};

typedef __be32(*nfsd4_enc_attr)(struct xdr_stream *xdr,
				const struct nfsd4_fattr_args *args);

static __be32 nfsd4_encode_fattr4__inval(struct xdr_stream *xdr,
					 const struct nfsd4_fattr_args *args)
{
	return nfserr_inval;
}

static __be32 nfsd4_encode_fattr4__noop(struct xdr_stream *xdr,
					const struct nfsd4_fattr_args *args)
{
	return nfs_ok;
}

static __be32 nfsd4_encode_fattr4__true(struct xdr_stream *xdr,
					const struct nfsd4_fattr_args *args)
{
	return nfsd4_encode_bool(xdr, true);
}

static __be32 nfsd4_encode_fattr4__false(struct xdr_stream *xdr,
					 const struct nfsd4_fattr_args *args)
{
	return nfsd4_encode_bool(xdr, false);
}

static __be32 nfsd4_encode_fattr4_supported_attrs(struct xdr_stream *xdr,
						  const struct nfsd4_fattr_args *args)
{
	struct nfsd4_compoundres *resp = args->rqstp->rq_resp;
	u32 minorversion = resp->cstate.minorversion;
	u32 supp[3];

	memcpy(supp, nfsd_suppattrs[minorversion], sizeof(supp));
	if (!IS_POSIXACL(d_inode(args->dentry)))
		supp[0] &= ~FATTR4_WORD0_ACL;
	if (!args->contextsupport)
		supp[2] &= ~FATTR4_WORD2_SECURITY_LABEL;

	return nfsd4_encode_bitmap4(xdr, supp[0], supp[1], supp[2]);
}

static __be32 nfsd4_encode_fattr4_type(struct xdr_stream *xdr,
				       const struct nfsd4_fattr_args *args)
{
	__be32 *p;

	p = xdr_reserve_space(xdr, XDR_UNIT);
	if (!p)
		return nfserr_resource;

	switch (args->stat.mode & S_IFMT) {
	case S_IFIFO:
		*p = cpu_to_be32(NF4FIFO);
		break;
	case S_IFCHR:
		*p = cpu_to_be32(NF4CHR);
		break;
	case S_IFDIR:
		*p = cpu_to_be32(NF4DIR);
		break;
	case S_IFBLK:
		*p = cpu_to_be32(NF4BLK);
		break;
	case S_IFLNK:
		*p = cpu_to_be32(NF4LNK);

Annotation

Implementation Notes