fs/nilfs2/sysfs.c
Source file repositories/reference/linux-study-clean/fs/nilfs2/sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
fs/nilfs2/sysfs.c- Extension
.c- Size
- 31875 bytes
- Lines
- 1141
- 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.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- 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/kobject.hnilfs.hmdt.hsufile.hcpfile.hsysfs.h
Detected Declarations
function nilfs_snapshot_inodes_count_showfunction nilfs_snapshot_blocks_count_showfunction nilfs_snapshot_README_showfunction nilfs_snapshot_attr_showfunction nilfs_snapshot_attr_storefunction nilfs_snapshot_attr_releasefunction nilfs_sysfs_create_snapshot_groupfunction nilfs_sysfs_delete_snapshot_groupfunction nilfs_mounted_snapshots_README_showfunction nilfs_checkpoints_checkpoints_number_showfunction nilfs_checkpoints_snapshots_number_showfunction nilfs_checkpoints_last_seg_checkpoint_showfunction nilfs_checkpoints_next_checkpoint_showfunction nilfs_checkpoints_README_showfunction nilfs_segments_segments_number_showfunction nilfs_segments_blocks_per_segment_showfunction nilfs_segments_clean_segments_showfunction nilfs_segments_dirty_segments_showfunction nilfs_segments_README_showfunction nilfs_segctor_last_pseg_block_showfunction nilfs_segctor_last_seg_sequence_showfunction nilfs_segctor_last_seg_checkpoint_showfunction nilfs_segctor_current_seg_sequence_showfunction nilfs_segctor_current_last_full_seg_showfunction nilfs_segctor_next_full_seg_showfunction nilfs_segctor_next_pseg_offset_showfunction nilfs_segctor_next_checkpoint_showfunction nilfs_segctor_last_seg_write_time_showfunction nilfs_segctor_last_seg_write_time_secs_showfunction nilfs_segctor_last_nongc_write_time_showfunction nilfs_segctor_last_nongc_write_time_secs_showfunction nilfs_segctor_dirty_data_blocks_count_showfunction nilfs_segctor_README_showfunction nilfs_superblock_sb_write_time_showfunction nilfs_superblock_sb_write_time_secs_showfunction nilfs_superblock_sb_write_count_showfunction nilfs_superblock_sb_update_frequency_showfunction nilfs_superblock_sb_update_frequency_storefunction nilfs_superblock_README_showfunction nilfs_dev_revision_showfunction nilfs_dev_blocksize_showfunction nilfs_dev_device_size_showfunction nilfs_dev_free_blocks_showfunction nilfs_dev_uuid_showfunction nilfs_dev_volume_name_showfunction nilfs_dev_README_showfunction nilfs_dev_attr_showfunction nilfs_dev_attr_store
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Sysfs support implementation.
*
* Copyright (C) 2005-2014 Nippon Telegraph and Telephone Corporation.
* Copyright (C) 2014 HGST, Inc., a Western Digital Company.
*
* Written by Vyacheslav Dubeyko <Vyacheslav.Dubeyko@hgst.com>
*/
#include <linux/kobject.h>
#include "nilfs.h"
#include "mdt.h"
#include "sufile.h"
#include "cpfile.h"
#include "sysfs.h"
/* /sys/fs/<nilfs>/ */
static struct kset *nilfs_kset;
#define NILFS_DEV_INT_GROUP_OPS(name, parent_name) \
static ssize_t nilfs_##name##_attr_show(struct kobject *kobj, \
struct attribute *attr, char *buf) \
{ \
struct the_nilfs *nilfs = container_of(kobj->parent, \
struct the_nilfs, \
ns_##parent_name##_kobj); \
struct nilfs_##name##_attr *a = container_of(attr, \
struct nilfs_##name##_attr, \
attr); \
return a->show ? a->show(a, nilfs, buf) : 0; \
} \
static ssize_t nilfs_##name##_attr_store(struct kobject *kobj, \
struct attribute *attr, \
const char *buf, size_t len) \
{ \
struct the_nilfs *nilfs = container_of(kobj->parent, \
struct the_nilfs, \
ns_##parent_name##_kobj); \
struct nilfs_##name##_attr *a = container_of(attr, \
struct nilfs_##name##_attr, \
attr); \
return a->store ? a->store(a, nilfs, buf, len) : 0; \
} \
static const struct sysfs_ops nilfs_##name##_attr_ops = { \
.show = nilfs_##name##_attr_show, \
.store = nilfs_##name##_attr_store, \
}
#define NILFS_DEV_INT_GROUP_TYPE(name, parent_name) \
static void nilfs_##name##_attr_release(struct kobject *kobj) \
{ \
struct nilfs_sysfs_##parent_name##_subgroups *subgroups = container_of(kobj, \
struct nilfs_sysfs_##parent_name##_subgroups, \
sg_##name##_kobj); \
complete(&subgroups->sg_##name##_kobj_unregister); \
} \
static const struct kobj_type nilfs_##name##_ktype = { \
.default_groups = nilfs_##name##_groups, \
.sysfs_ops = &nilfs_##name##_attr_ops, \
.release = nilfs_##name##_attr_release, \
}
#define NILFS_DEV_INT_GROUP_FNS(name, parent_name) \
static int nilfs_sysfs_create_##name##_group(struct the_nilfs *nilfs) \
{ \
struct kobject *parent; \
struct kobject *kobj; \
struct completion *kobj_unregister; \
struct nilfs_sysfs_##parent_name##_subgroups *subgroups; \
int err; \
subgroups = nilfs->ns_##parent_name##_subgroups; \
kobj = &subgroups->sg_##name##_kobj; \
kobj_unregister = &subgroups->sg_##name##_kobj_unregister; \
parent = &nilfs->ns_##parent_name##_kobj; \
kobj->kset = nilfs_kset; \
init_completion(kobj_unregister); \
err = kobject_init_and_add(kobj, &nilfs_##name##_ktype, parent, \
#name); \
if (err) \
kobject_put(kobj); \
return err; \
} \
static void nilfs_sysfs_delete_##name##_group(struct the_nilfs *nilfs) \
{ \
kobject_put(&nilfs->ns_##parent_name##_subgroups->sg_##name##_kobj); \
}
/************************************************************************
Annotation
- Immediate include surface: `linux/kobject.h`, `nilfs.h`, `mdt.h`, `sufile.h`, `cpfile.h`, `sysfs.h`.
- Detected declarations: `function nilfs_snapshot_inodes_count_show`, `function nilfs_snapshot_blocks_count_show`, `function nilfs_snapshot_README_show`, `function nilfs_snapshot_attr_show`, `function nilfs_snapshot_attr_store`, `function nilfs_snapshot_attr_release`, `function nilfs_sysfs_create_snapshot_group`, `function nilfs_sysfs_delete_snapshot_group`, `function nilfs_mounted_snapshots_README_show`, `function nilfs_checkpoints_checkpoints_number_show`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.