fs/nfsd/export.c

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

File Facts

System
Linux kernel
Corpus path
fs/nfsd/export.c
Extension
.c
Size
56273 bytes
Lines
2253
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

key_len(ek->ek_fsidtype), ek->ek_fsid)) {
			nla_nest_cancel(skb, nest);
			break;
		}

		nla_nest_end(skb, nest);
		cb->args[0] = seqnos[i];
		emitted++;
	}

	if (!emitted) {
		genlmsg_cancel(skb, hdr);
		ret = -EMSGSIZE;
		goto out_put;
	}

	genlmsg_end(skb, hdr);
	ret = skb->len;
out_put:
	for (i = 0; i < cnt; i++)
		cache_put(items[i], cd);
out_alloc:
	kfree(seqnos);
	kfree(items);
out_unlock:
	mutex_unlock(&nfsd_mutex);
	return ret;
}

/**
 * nfsd_nl_parse_one_expkey - parse one expkey entry from netlink
 * @cd: cache_detail for the expkey cache
 * @attr: nested attribute containing expkey fields
 *
 * Parses one expkey entry from a netlink message and updates the
 * cache. Mirrors the logic in expkey_parse().
 *
 * Returns 0 on success or a negative errno.
 */
static int nfsd_nl_parse_one_expkey(struct cache_detail *cd,
				    struct nlattr *attr)
{
	struct nlattr *tb[NFSD_A_EXPKEY_PATH + 1];
	struct auth_domain *dom = NULL;
	struct svc_expkey key;
	struct svc_expkey *ek = NULL;
	struct timespec64 boot;
	int err;
	u8 fsidtype;
	int fsid_len;

	err = nla_parse_nested(tb, NFSD_A_EXPKEY_PATH, attr,
			       nfsd_expkey_nl_policy, NULL);
	if (err)
		return err;

	/* client (required) */
	if (!tb[NFSD_A_EXPKEY_CLIENT])
		return -EINVAL;

	dom = auth_domain_find(nla_data(tb[NFSD_A_EXPKEY_CLIENT]));
	if (!dom)
		return -ENOENT;

	/* fsidtype (required) */
	if (!tb[NFSD_A_EXPKEY_FSIDTYPE]) {
		err = -EINVAL;
		goto out_dom;
	}
	fsidtype = nla_get_u8(tb[NFSD_A_EXPKEY_FSIDTYPE]);
	if (key_len(fsidtype) == 0) {
		err = -EINVAL;
		goto out_dom;
	}

	/* fsid (required) */
	if (!tb[NFSD_A_EXPKEY_FSID]) {
		err = -EINVAL;
		goto out_dom;
	}
	fsid_len = nla_len(tb[NFSD_A_EXPKEY_FSID]);
	if (fsid_len != key_len(fsidtype)) {
		err = -EINVAL;
		goto out_dom;
	}

	/* expiry (required, wallclock seconds) */
	if (!tb[NFSD_A_EXPKEY_EXPIRY]) {
		err = -EINVAL;
		goto out_dom;

Annotation

Implementation Notes