drivers/block/rnbd/rnbd-srv-sysfs.c
Source file repositories/reference/linux-study-clean/drivers/block/rnbd/rnbd-srv-sysfs.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/block/rnbd/rnbd-srv-sysfs.c- Extension
.c- Size
- 6152 bytes
- Lines
- 251
- Domain
- Driver Families
- Bucket
- drivers/block
- Inferred role
- Driver Families: implementation source
- Status
- source implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kobject.hlinux/sysfs.hlinux/stat.hlinux/list.hlinux/moduleparam.hlinux/device.hrnbd-srv.h
Detected Declarations
function rnbd_srv_dev_releasefunction rnbd_srv_create_dev_sysfsfunction rnbd_srv_destroy_dev_sysfsfunction read_only_showfunction access_mode_showfunction mapping_path_showfunction rnbd_srv_dev_session_force_close_showfunction rnbd_srv_dev_session_force_close_storefunction rnbd_srv_destroy_dev_session_sysfsfunction rnbd_srv_sess_dev_releasefunction rnbd_srv_create_dev_session_sysfsfunction rnbd_srv_create_sysfs_filesfunction rnbd_srv_destroy_sysfs_files
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* RDMA Network Block Driver
*
* Copyright (c) 2014 - 2018 ProfitBricks GmbH. All rights reserved.
* Copyright (c) 2018 - 2019 1&1 IONOS Cloud GmbH. All rights reserved.
* Copyright (c) 2019 - 2020 1&1 IONOS SE. All rights reserved.
*/
#undef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME " L" __stringify(__LINE__) ": " fmt
#include <linux/kobject.h>
#include <linux/sysfs.h>
#include <linux/stat.h>
#include <linux/list.h>
#include <linux/moduleparam.h>
#include <linux/device.h>
#include "rnbd-srv.h"
static struct device *rnbd_dev;
static const struct class rnbd_dev_class = {
.name = "rnbd-server",
};
static struct kobject *rnbd_devs_kobj;
static void rnbd_srv_dev_release(struct kobject *kobj)
{
struct rnbd_srv_dev *dev;
dev = container_of(kobj, struct rnbd_srv_dev, dev_kobj);
kfree(dev);
}
static const struct kobj_type dev_ktype = {
.sysfs_ops = &kobj_sysfs_ops,
.release = rnbd_srv_dev_release
};
int rnbd_srv_create_dev_sysfs(struct rnbd_srv_dev *dev,
struct block_device *bdev)
{
struct kobject *bdev_kobj;
int ret;
ret = kobject_init_and_add(&dev->dev_kobj, &dev_ktype,
rnbd_devs_kobj, "%pg", bdev);
if (ret) {
kobject_put(&dev->dev_kobj);
return ret;
}
dev->dev_sessions_kobj = kobject_create_and_add("sessions",
&dev->dev_kobj);
if (!dev->dev_sessions_kobj) {
ret = -ENOMEM;
goto free_dev_kobj;
}
bdev_kobj = &disk_to_dev(bdev->bd_disk)->kobj;
ret = sysfs_create_link(&dev->dev_kobj, bdev_kobj, "block_dev");
if (ret)
goto put_sess_kobj;
return 0;
put_sess_kobj:
kobject_put(dev->dev_sessions_kobj);
free_dev_kobj:
kobject_del(&dev->dev_kobj);
kobject_put(&dev->dev_kobj);
return ret;
}
void rnbd_srv_destroy_dev_sysfs(struct rnbd_srv_dev *dev)
{
sysfs_remove_link(&dev->dev_kobj, "block_dev");
kobject_del(dev->dev_sessions_kobj);
kobject_put(dev->dev_sessions_kobj);
kobject_del(&dev->dev_kobj);
kobject_put(&dev->dev_kobj);
}
static ssize_t read_only_show(struct kobject *kobj, struct kobj_attribute *attr,
char *page)
{
struct rnbd_srv_sess_dev *sess_dev;
sess_dev = container_of(kobj, struct rnbd_srv_sess_dev, kobj);
Annotation
- Immediate include surface: `linux/kobject.h`, `linux/sysfs.h`, `linux/stat.h`, `linux/list.h`, `linux/moduleparam.h`, `linux/device.h`, `rnbd-srv.h`.
- Detected declarations: `function rnbd_srv_dev_release`, `function rnbd_srv_create_dev_sysfs`, `function rnbd_srv_destroy_dev_sysfs`, `function read_only_show`, `function access_mode_show`, `function mapping_path_show`, `function rnbd_srv_dev_session_force_close_show`, `function rnbd_srv_dev_session_force_close_store`, `function rnbd_srv_destroy_dev_session_sysfs`, `function rnbd_srv_sess_dev_release`.
- Atlas domain: Driver Families / drivers/block.
- Implementation status: source implementation candidate.
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.