fs/nfs/sysfs.c

Source file repositories/reference/linux-study-clean/fs/nfs/sysfs.c

File Facts

System
Linux kernel
Corpus path
fs/nfs/sysfs.c
Extension
.c
Size
11685 bytes
Lines
475
Domain
Core OS
Bucket
VFS And Filesystem Core
Inferred role
Core OS: exported/initcall integration point
Status
integration 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

if (!(server->flags & NFS_MOUNT_SHUTDOWN)) {
			rcu_read_unlock();
			return;
		}
	}
	rcu_read_unlock();
	nfs_mark_client_ready(clp, -EIO);
	shutdown_client(clp->cl_rpcclient);
}

static ssize_t
shutdown_show(struct kobject *kobj, struct kobj_attribute *attr,
				char *buf)
{
	struct nfs_server *server = container_of(kobj, struct nfs_server, kobj);
	bool shutdown = server->flags & NFS_MOUNT_SHUTDOWN;
	return sysfs_emit(buf, "%d\n", shutdown);
}

static ssize_t
shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,
				const char *buf, size_t count)
{
	struct nfs_server *server;
	int ret, val;

	server = container_of(kobj, struct nfs_server, kobj);

	ret = kstrtoint(buf, 0, &val);
	if (ret)
		return ret;

	if (val != 1)
		return -EINVAL;

	/* already shut down? */
	if (server->flags & NFS_MOUNT_SHUTDOWN)
		goto out;

	server->flags |= NFS_MOUNT_SHUTDOWN;
	shutdown_client(server->client);

	if (!IS_ERR(server->client_acl))
		shutdown_client(server->client_acl);

	if (server->nlm_host)
		nlmclnt_shutdown_rpc_clnt(server->nlm_host);
out:
	shutdown_nfs_client(server->nfs_client);
	return count;
}

static struct kobj_attribute nfs_sysfs_attr_shutdown = __ATTR_RW(shutdown);

#if IS_ENABLED(CONFIG_NFS_V4)
static ssize_t
implid_domain_show(struct kobject *kobj, struct kobj_attribute *attr,
				char *buf)
{
	struct nfs_server *server = container_of(kobj, struct nfs_server, kobj);
	struct nfs41_impl_id *impl_id = server->nfs_client->cl_implid;

	if (!impl_id || strlen(impl_id->domain) == 0)
		return 0; //sysfs_emit(buf, "");
	return sysfs_emit(buf, "%s\n", impl_id->domain);
}

static struct kobj_attribute nfs_sysfs_attr_implid_domain = __ATTR_RO(implid_domain);


static ssize_t
implid_name_show(struct kobject *kobj, struct kobj_attribute *attr,
				char *buf)
{
	struct nfs_server *server = container_of(kobj, struct nfs_server, kobj);
	struct nfs41_impl_id *impl_id = server->nfs_client->cl_implid;

	if (!impl_id || strlen(impl_id->name) == 0)
		return 0; //sysfs_emit(buf, "");
	return sysfs_emit(buf, "%s\n", impl_id->name);
}

static struct kobj_attribute nfs_sysfs_attr_implid_name = __ATTR_RO(implid_name);

#endif /* IS_ENABLED(CONFIG_NFS_V4) */

#define RPC_CLIENT_NAME_SIZE 64

void nfs_sysfs_link_rpc_client(struct nfs_server *server,
			struct rpc_clnt *clnt, const char *uniq)

Annotation

Implementation Notes