]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/aufs/sysaufs.c
x86/mm: Add TLB purge to free pmd/pte page interfaces
[mirror_ubuntu-bionic-kernel.git] / fs / aufs / sysaufs.c
CommitLineData
c088e31d
SF
1/*
2 * Copyright (C) 2005-2017 Junjiro R. Okajima
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, see <http://www.gnu.org/licenses/>.
16 */
17
18/*
19 * sysfs interface and lifetime management
20 * they are necessary regardless sysfs is disabled.
21 */
22
23#include <linux/random.h>
24#include "aufs.h"
25
26unsigned long sysaufs_si_mask;
27struct kset *sysaufs_kset;
28
29#define AuSiAttr(_name) { \
30 .attr = { .name = __stringify(_name), .mode = 0444 }, \
31 .show = sysaufs_si_##_name, \
32}
33
34static struct sysaufs_si_attr sysaufs_si_attr_xi_path = AuSiAttr(xi_path);
35struct attribute *sysaufs_si_attrs[] = {
36 &sysaufs_si_attr_xi_path.attr,
37 NULL,
38};
39
40static const struct sysfs_ops au_sbi_ops = {
41 .show = sysaufs_si_show
42};
43
44static struct kobj_type au_sbi_ktype = {
45 .release = au_si_free,
46 .sysfs_ops = &au_sbi_ops,
47 .default_attrs = sysaufs_si_attrs
48};
49
50/* ---------------------------------------------------------------------- */
51
52int sysaufs_si_init(struct au_sbinfo *sbinfo)
53{
54 int err;
55
56 sbinfo->si_kobj.kset = sysaufs_kset;
57 /* cf. sysaufs_name() */
58 err = kobject_init_and_add
59 (&sbinfo->si_kobj, &au_sbi_ktype, /*&sysaufs_kset->kobj*/NULL,
60 SysaufsSiNamePrefix "%lx", sysaufs_si_id(sbinfo));
61
62 dbgaufs_si_null(sbinfo);
63 if (!err) {
64 err = dbgaufs_si_init(sbinfo);
65 if (unlikely(err))
66 kobject_put(&sbinfo->si_kobj);
67 }
68 return err;
69}
70
71void sysaufs_fin(void)
72{
73 dbgaufs_fin();
74 sysfs_remove_group(&sysaufs_kset->kobj, sysaufs_attr_group);
75 kset_unregister(sysaufs_kset);
76}
77
78int __init sysaufs_init(void)
79{
80 int err;
81
82 do {
83 get_random_bytes(&sysaufs_si_mask, sizeof(sysaufs_si_mask));
84 } while (!sysaufs_si_mask);
85
86 err = -EINVAL;
87 sysaufs_kset = kset_create_and_add(AUFS_NAME, NULL, fs_kobj);
88 if (unlikely(!sysaufs_kset))
89 goto out;
90 err = PTR_ERR(sysaufs_kset);
91 if (IS_ERR(sysaufs_kset))
92 goto out;
93 err = sysfs_create_group(&sysaufs_kset->kobj, sysaufs_attr_group);
94 if (unlikely(err)) {
95 kset_unregister(sysaufs_kset);
96 goto out;
97 }
98
99 err = dbgaufs_init();
100 if (unlikely(err))
101 sysaufs_fin();
102out:
103 return err;
104}