Linux Audio

Check our new training course

Loading...
v4.10.11
 1/* -*- mode: c; c-basic-offset: 8; -*-
 2 * vim: noexpandtab sw=8 ts=8 sts=0:
 3 *
 4 * sys.c
 5 *
 6 * OCFS2 cluster sysfs interface
 7 *
 8 * Copyright (C) 2005 Oracle.  All rights reserved.
 9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License as published by the Free Software Foundation,
13 * version 2 of the License.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 * General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public
21 * License along with this program; if not, write to the
22 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 * Boston, MA 021110-1307, USA.
24 *
25 */
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/kobject.h>
30#include <linux/sysfs.h>
31#include <linux/fs.h>
32
33#include "ocfs2_nodemanager.h"
34#include "masklog.h"
35#include "sys.h"
36
37
38static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr,
39			    char *buf)
40{
41	return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION);
42}
43static struct kobj_attribute attr_version =
44	__ATTR(interface_revision, S_IRUGO, version_show, NULL);
45
46static struct attribute *o2cb_attrs[] = {
47	&attr_version.attr,
48	NULL,
49};
50
51static struct attribute_group o2cb_attr_group = {
52	.attrs = o2cb_attrs,
53};
54
55static struct kset *o2cb_kset;
56
57void o2cb_sys_shutdown(void)
58{
59	mlog_sys_shutdown();
60	kset_unregister(o2cb_kset);
61}
62
63int o2cb_sys_init(void)
64{
65	int ret;
66
67	o2cb_kset = kset_create_and_add("o2cb", NULL, fs_kobj);
68	if (!o2cb_kset)
69		return -ENOMEM;
70
71	ret = sysfs_create_group(&o2cb_kset->kobj, &o2cb_attr_group);
72	if (ret)
73		goto error;
74
75	ret = mlog_sys_init(o2cb_kset);
76	if (ret)
77		goto error;
78	return 0;
79error:
80	kset_unregister(o2cb_kset);
81	return ret;
82}
v6.13.7
 1// SPDX-License-Identifier: GPL-2.0-only
 2/*
 
 3 * sys.c
 4 *
 5 * OCFS2 cluster sysfs interface
 6 *
 7 * Copyright (C) 2005 Oracle.  All rights reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 8 */
 9
10#include <linux/kernel.h>
11#include <linux/module.h>
12#include <linux/kobject.h>
13#include <linux/sysfs.h>
14#include <linux/fs.h>
15
16#include "ocfs2_nodemanager.h"
17#include "masklog.h"
18#include "sys.h"
19
20
21static ssize_t version_show(struct kobject *kobj, struct kobj_attribute *attr,
22			    char *buf)
23{
24	return snprintf(buf, PAGE_SIZE, "%u\n", O2NM_API_VERSION);
25}
26static struct kobj_attribute attr_version =
27	__ATTR(interface_revision, S_IRUGO, version_show, NULL);
28
29static struct attribute *o2cb_attrs[] = {
30	&attr_version.attr,
31	NULL,
32};
33
34static struct attribute_group o2cb_attr_group = {
35	.attrs = o2cb_attrs,
36};
37
38static struct kset *o2cb_kset;
39
40void o2cb_sys_shutdown(void)
41{
42	mlog_sys_shutdown();
43	kset_unregister(o2cb_kset);
44}
45
46int o2cb_sys_init(void)
47{
48	int ret;
49
50	o2cb_kset = kset_create_and_add("o2cb", NULL, fs_kobj);
51	if (!o2cb_kset)
52		return -ENOMEM;
53
54	ret = sysfs_create_group(&o2cb_kset->kobj, &o2cb_attr_group);
55	if (ret)
56		goto error;
57
58	ret = mlog_sys_init(o2cb_kset);
59	if (ret)
60		goto error;
61	return 0;
62error:
63	kset_unregister(o2cb_kset);
64	return ret;
65}