2
* Copyright (C) 2007-2008 Junjiro Okajima
4
* This program, aufs is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will 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.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20
* sysfs interface and lifetime management
21
* they are necessary regardless sysfs is disabled.
23
* $Id: sysaufs.c,v 1.4 2008/04/28 03:05:39 sfjro Exp $
27
#include <linux/module.h>
28
#include <linux/sysfs.h>
31
/* ---------------------------------------------------------------------- */
33
/* super_blocks list is not exported */
34
DEFINE_MUTEX(au_sbilist_mtx);
35
LIST_HEAD(au_sbilist);
37
/* ---------------------------------------------------------------------- */
39
static struct kset au_kset;
41
#define AuSbiAttr(_name) { \
42
.attr = { .name = __stringify(_name), .mode = 0444 }, \
43
.show = sysaufs_sbi_##_name, \
46
static struct au_sbi_attr au_sbi_attr_xino = AuSbiAttr(xino),
47
au_sbi_attr_mntpnt1 = AuSbiAttr(mntpnt1);
49
struct attribute *au_sbi_attrs[] = {
50
&au_sbi_attr_xino.attr,
51
&au_sbi_attr_mntpnt1.attr,
55
static struct sysfs_ops au_sbi_ops = {
56
.show = sysaufs_sbi_show
59
static struct kobj_type au_sbi_ktype = {
60
.release = au_si_free,
61
.sysfs_ops = &au_sbi_ops,
62
.default_attrs = au_sbi_attrs,
65
/* ---------------------------------------------------------------------- */
67
int sysaufs_si_init(struct au_sbinfo *sbinfo)
71
sbinfo->si_kobj.kset = &au_kset;
72
err = kobject_init_and_add(&sbinfo->si_kobj, &au_sbi_ktype,
73
NULL/*&au_kset.kobj*/,
74
SysaufsSb_PREFIX "%p", sbinfo);
80
/* ---------------------------------------------------------------------- */
82
void sysaufs_fin(void)
84
AuDebugOn(!list_empty(&au_sbilist));
85
sysfs_remove_group(&au_kset.kobj, au_attr_group);
86
kset_unregister(&au_kset);
89
int __init sysaufs_init(void)
94
au_kset.kobj.parent = fs_kobj;
95
kobject_set_name(&au_kset.kobj, AUFS_NAME);
96
au_kset.kobj.ktype = au_ktype;
97
err = kset_register(&au_kset);
100
err = sysfs_create_group(&au_kset.kobj, au_attr_group);
102
kset_unregister(&au_kset);