mirror of
https://github.com/versity/scoutfs.git
synced 2026-04-18 20:45:04 +00:00
Add sysfs attribute creation that can provide the parent dir kobject instead of always creating the sysfs object dir off of the main per-mount dir. Signed-off-by: Zach Brown <zab@versity.com>
59 lines
1.7 KiB
C
59 lines
1.7 KiB
C
#ifndef _SCOUTFS_SYSFS_H_
|
|
#define _SCOUTFS_SYSFS_H_
|
|
|
|
#include <linux/kobject.h>
|
|
|
|
/*
|
|
* We have some light wrappers around sysfs attributes to make it safe
|
|
* to tear down the attributes before freeing the data they describe.
|
|
*/
|
|
|
|
#define SCOUTFS_ATTR_RO(_name) \
|
|
static struct kobj_attribute scoutfs_attr_##_name = __ATTR_RO(_name)
|
|
#define SCOUTFS_ATTR_RW(_name) \
|
|
static struct kobj_attribute scoutfs_attr_##_name = __ATTR_RW(_name)
|
|
|
|
#define SCOUTFS_ATTR_PTR(_name) \
|
|
&scoutfs_attr_##_name.attr
|
|
|
|
struct scoutfs_sysfs_attrs {
|
|
struct super_block *sb;
|
|
char *name;
|
|
struct completion comp;
|
|
|
|
struct kobject kobj;
|
|
struct kobj_type ktype;
|
|
};
|
|
|
|
#define SCOUTFS_SYSFS_ATTRS(kobj) \
|
|
container_of(kobj, struct scoutfs_sysfs_attrs, kobj)
|
|
|
|
#define SCOUTFS_SYSFS_ATTRS_SB(kobj) \
|
|
(SCOUTFS_SYSFS_ATTRS(kobj)->sb)
|
|
|
|
#define DECLARE_SCOUTFS_SYSFS_ATTRS(name, kobj) \
|
|
struct scoutfs_sysfs_attrs *ssa = SCOUTFS_SYSFS_ATTRS(kobj)
|
|
|
|
void scoutfs_sysfs_init_attrs(struct super_block *sb,
|
|
struct scoutfs_sysfs_attrs *ssa);
|
|
int scoutfs_sysfs_create_attrs_parent(struct super_block *sb,
|
|
struct kobject *parent,
|
|
struct scoutfs_sysfs_attrs *ssa,
|
|
struct attribute **attrs, char *fmt, ...);
|
|
#define scoutfs_sysfs_create_attrs(sb, ssa, attrs, fmt, args...) \
|
|
scoutfs_sysfs_create_attrs_parent(sb, scoutfs_sysfs_sb_dir(sb), \
|
|
ssa, attrs, fmt, ##args)
|
|
|
|
void scoutfs_sysfs_destroy_attrs(struct super_block *sb,
|
|
struct scoutfs_sysfs_attrs *ssa);
|
|
|
|
struct kobject *scoutfs_sysfs_sb_dir(struct super_block *sb);
|
|
|
|
int scoutfs_setup_sysfs(struct super_block *sb);
|
|
void scoutfs_destroy_sysfs(struct super_block *sb);
|
|
|
|
int __init scoutfs_sysfs_init(void);
|
|
void __exit scoutfs_sysfs_exit(void);
|
|
|
|
#endif
|