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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kobject.hlinux/sysfs.hlinux/fs.hlinux/slab.hlinux/netdevice.hlinux/string.hlinux/nfs_fs.hnet/net_namespace.hlinux/rcupdate.hlinux/lockd/bind.hinternal.hnfs4_fs.hnetns.hsysfs.h
Detected Declarations
function nfs_kset_releasefunction nfs_sysfs_initfunction nfs_sysfs_exitfunction nfs_netns_identifier_showfunction nfs_string_stripfunction nfs_netns_identifier_storefunction nfs_netns_client_releasefunction nfs_netns_object_releasefunction nfs_netns_sysfs_setupfunction nfs_netns_sysfs_destroyfunction shutdown_match_clientfunction shutdown_clientfunction shutdown_nfs_clientfunction shutdown_showfunction shutdown_storefunction implid_domain_showfunction implid_name_showfunction nfs_sysfs_link_rpc_clientfunction nfs_sysfs_sb_releasefunction nfs_sysfs_add_nfsv41_serverfunction nfs_sysfs_add_nfsv41_serverfunction nfs_sysfs_add_nfs_localio_serverfunction nfs_sysfs_add_nfs_localio_serverfunction nfs_sysfs_move_server_to_sbfunction nfs_sysfs_move_sb_to_serverfunction nfs_sysfs_remove_serverexport nfs_sysfs_link_rpc_clientexport nfs_sysfs_add_server
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
- Immediate include surface: `linux/module.h`, `linux/kobject.h`, `linux/sysfs.h`, `linux/fs.h`, `linux/slab.h`, `linux/netdevice.h`, `linux/string.h`, `linux/nfs_fs.h`.
- Detected declarations: `function nfs_kset_release`, `function nfs_sysfs_init`, `function nfs_sysfs_exit`, `function nfs_netns_identifier_show`, `function nfs_string_strip`, `function nfs_netns_identifier_store`, `function nfs_netns_client_release`, `function nfs_netns_object_release`, `function nfs_netns_sysfs_setup`, `function nfs_netns_sysfs_destroy`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.