2
by Alessio Igor Bogani
Add new lowlatency kernel flavour |
1 |
/*
|
3
by Luke Yelavich, Andy Whitcroft, Chase Douglas, Eugeni Dodonov, Ingo Molnar, Johannes Berg, John Johansen, Kees Cook, Leann Ogasawara, Robert Hooker, Seth Heasley, Tim Gardner, Luke Yelavich, Upstream Kernel Changes
[ Andy Whitcroft ] |
2 |
* Copyright (C) 2005-2012 Junjiro R. Okajima
|
2
by Alessio Igor Bogani
Add new lowlatency kernel flavour |
3 |
*
|
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.
|
|
8 |
*
|
|
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.
|
|
13 |
*
|
|
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
|
|
17 |
*/
|
|
18 |
||
19 |
/*
|
|
20 |
* sysfs interface and lifetime management
|
|
21 |
* they are necessary regardless sysfs is disabled.
|
|
22 |
*/
|
|
23 |
||
24 |
#include <linux/random.h> |
|
25 |
#include "aufs.h" |
|
26 |
||
27 |
unsigned long sysaufs_si_mask; |
|
28 |
struct kset *sysaufs_kset; |
|
29 |
||
30 |
#define AuSiAttr(_name) { \
|
|
31 |
.attr = { .name = __stringify(_name), .mode = 0444 }, \
|
|
32 |
.show = sysaufs_si_##_name, \
|
|
33 |
}
|
|
34 |
||
35 |
static struct sysaufs_si_attr sysaufs_si_attr_xi_path = AuSiAttr(xi_path); |
|
36 |
struct attribute *sysaufs_si_attrs[] = { |
|
37 |
&sysaufs_si_attr_xi_path.attr, |
|
38 |
NULL, |
|
39 |
};
|
|
40 |
||
41 |
static const struct sysfs_ops au_sbi_ops = { |
|
42 |
.show = sysaufs_si_show |
|
43 |
};
|
|
44 |
||
45 |
static struct kobj_type au_sbi_ktype = { |
|
46 |
.release = au_si_free, |
|
47 |
.sysfs_ops = &au_sbi_ops, |
|
48 |
.default_attrs = sysaufs_si_attrs |
|
49 |
};
|
|
50 |
||
51 |
/* ---------------------------------------------------------------------- */
|
|
52 |
||
53 |
int sysaufs_si_init(struct au_sbinfo *sbinfo) |
|
54 |
{
|
|
55 |
int err; |
|
56 |
||
57 |
sbinfo->si_kobj.kset = sysaufs_kset; |
|
58 |
/* cf. sysaufs_name() */
|
|
59 |
err = kobject_init_and_add |
|
60 |
(&sbinfo->si_kobj, &au_sbi_ktype, /*&sysaufs_kset->kobj*/NULL, |
|
61 |
SysaufsSiNamePrefix "%lx", sysaufs_si_id(sbinfo)); |
|
62 |
||
63 |
dbgaufs_si_null(sbinfo); |
|
64 |
if (!err) { |
|
65 |
err = dbgaufs_si_init(sbinfo); |
|
66 |
if (unlikely(err)) |
|
67 |
kobject_put(&sbinfo->si_kobj); |
|
68 |
}
|
|
69 |
return err; |
|
70 |
}
|
|
71 |
||
72 |
void sysaufs_fin(void) |
|
73 |
{
|
|
74 |
dbgaufs_fin(); |
|
75 |
sysfs_remove_group(&sysaufs_kset->kobj, sysaufs_attr_group); |
|
76 |
kset_unregister(sysaufs_kset); |
|
77 |
}
|
|
78 |
||
79 |
int __init sysaufs_init(void) |
|
80 |
{
|
|
81 |
int err; |
|
82 |
||
83 |
do { |
|
84 |
get_random_bytes(&sysaufs_si_mask, sizeof(sysaufs_si_mask)); |
|
85 |
} while (!sysaufs_si_mask); |
|
86 |
||
87 |
err = -EINVAL; |
|
88 |
sysaufs_kset = kset_create_and_add(AUFS_NAME, NULL, fs_kobj); |
|
89 |
if (unlikely(!sysaufs_kset)) |
|
90 |
goto out; |
|
91 |
err = PTR_ERR(sysaufs_kset); |
|
92 |
if (IS_ERR(sysaufs_kset)) |
|
93 |
goto out; |
|
94 |
err = sysfs_create_group(&sysaufs_kset->kobj, sysaufs_attr_group); |
|
95 |
if (unlikely(err)) { |
|
96 |
kset_unregister(sysaufs_kset); |
|
97 |
goto out; |
|
98 |
}
|
|
99 |
||
100 |
err = dbgaufs_init(); |
|
101 |
if (unlikely(err)) |
|
102 |
sysaufs_fin(); |
|
103 |
out: |
|
104 |
return err; |
|
105 |
}
|