]> Git Repo - linux.git/blame - fs/xfs/xfs_sysfs.c
xfs: add xlog sysfs kobject and attribute handlers
[linux.git] / fs / xfs / xfs_sysfs.c
CommitLineData
a31b1d3d
BF
1/*
2 * Copyright (c) 2014 Red Hat, Inc.
3 * All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 */
18
19#include "xfs.h"
20#include "xfs_sysfs.h"
baff4e44
BF
21#include "xfs_log_format.h"
22#include "xfs_log.h"
23#include "xfs_log_priv.h"
a31b1d3d
BF
24
25struct xfs_sysfs_attr {
26 struct attribute attr;
27 ssize_t (*show)(char *buf, void *data);
28 ssize_t (*store)(const char *buf, size_t count, void *data);
29};
30
31static inline struct xfs_sysfs_attr *
32to_attr(struct attribute *attr)
33{
34 return container_of(attr, struct xfs_sysfs_attr, attr);
35}
36
37#define XFS_SYSFS_ATTR_RW(name) \
38 static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RW(name)
39#define XFS_SYSFS_ATTR_RO(name) \
40 static struct xfs_sysfs_attr xfs_sysfs_attr_##name = __ATTR_RO(name)
41
42#define ATTR_LIST(name) &xfs_sysfs_attr_##name.attr
43
44/*
45 * xfs_mount kobject. This currently has no attributes and thus no need for show
46 * and store helpers. The mp kobject serves as the per-mount parent object that
47 * is identified by the fsname under sysfs.
48 */
49
50struct kobj_type xfs_mp_ktype = {
51 .release = xfs_sysfs_release,
52};
baff4e44
BF
53
54/* xlog */
55
56static struct attribute *xfs_log_attrs[] = {
57 NULL,
58};
59
60static inline struct xlog *
61to_xlog(struct kobject *kobject)
62{
63 struct xfs_kobj *kobj = to_kobj(kobject);
64 return container_of(kobj, struct xlog, l_kobj);
65}
66
67STATIC ssize_t
68xfs_log_show(
69 struct kobject *kobject,
70 struct attribute *attr,
71 char *buf)
72{
73 struct xlog *log = to_xlog(kobject);
74 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
75
76 return xfs_attr->show ? xfs_attr->show(buf, log) : 0;
77}
78
79STATIC ssize_t
80xfs_log_store(
81 struct kobject *kobject,
82 struct attribute *attr,
83 const char *buf,
84 size_t count)
85{
86 struct xlog *log = to_xlog(kobject);
87 struct xfs_sysfs_attr *xfs_attr = to_attr(attr);
88
89 return xfs_attr->store ? xfs_attr->store(buf, count, log) : 0;
90}
91
92static struct sysfs_ops xfs_log_ops = {
93 .show = xfs_log_show,
94 .store = xfs_log_store,
95};
96
97struct kobj_type xfs_log_ktype = {
98 .release = xfs_sysfs_release,
99 .sysfs_ops = &xfs_log_ops,
100 .default_attrs = xfs_log_attrs,
101};
This page took 0.039312 seconds and 4 git commands to generate.