~ubuntu-branches/ubuntu/vivid/aufs/vivid

« back to all changes in this revision

Viewing changes to fs/aufs25/sysaufs.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20080506183550-0b6c974kkgc46oeh
Tags: 0+20080506-1
* New upstream release, supports Kernel 2.6.25 (Closes: #479717)
* Fix building with older Kernels (Closes: #475042)
* Update the patches 01, 04 and 07 to also patch fs/aufs25

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007-2008 Junjiro 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, 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
 * $Id: sysaufs.c,v 1.4 2008/04/28 03:05:39 sfjro Exp $
 
24
 */
 
25
 
 
26
#include <linux/fs.h>
 
27
#include <linux/module.h>
 
28
#include <linux/sysfs.h>
 
29
#include "aufs.h"
 
30
 
 
31
/* ---------------------------------------------------------------------- */
 
32
 
 
33
/* super_blocks list is not exported */
 
34
DEFINE_MUTEX(au_sbilist_mtx);
 
35
LIST_HEAD(au_sbilist);
 
36
 
 
37
/* ---------------------------------------------------------------------- */
 
38
 
 
39
static struct kset au_kset;
 
40
 
 
41
#define AuSbiAttr(_name) { \
 
42
        .attr   = { .name = __stringify(_name), .mode = 0444 }, \
 
43
        .show   = sysaufs_sbi_##_name,                          \
 
44
}
 
45
 
 
46
static struct au_sbi_attr au_sbi_attr_xino = AuSbiAttr(xino),
 
47
        au_sbi_attr_mntpnt1 = AuSbiAttr(mntpnt1);
 
48
 
 
49
struct attribute *au_sbi_attrs[] = {
 
50
        &au_sbi_attr_xino.attr,
 
51
        &au_sbi_attr_mntpnt1.attr,
 
52
        NULL,
 
53
};
 
54
 
 
55
static struct sysfs_ops au_sbi_ops = {
 
56
        .show   = sysaufs_sbi_show
 
57
};
 
58
 
 
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,
 
63
};
 
64
 
 
65
/* ---------------------------------------------------------------------- */
 
66
 
 
67
int sysaufs_si_init(struct au_sbinfo *sbinfo)
 
68
{
 
69
        int err;
 
70
 
 
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);
 
75
        AuTraceErr(err);
 
76
        return err;
 
77
}
 
78
 
 
79
 
 
80
/* ---------------------------------------------------------------------- */
 
81
 
 
82
void sysaufs_fin(void)
 
83
{
 
84
        AuDebugOn(!list_empty(&au_sbilist));
 
85
        sysfs_remove_group(&au_kset.kobj, au_attr_group);
 
86
        kset_unregister(&au_kset);
 
87
}
 
88
 
 
89
int __init sysaufs_init(void)
 
90
{
 
91
        int err;
 
92
 
 
93
        sysaufs_brs_init();
 
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);
 
98
        if (unlikely(err))
 
99
                goto out;
 
100
        err = sysfs_create_group(&au_kset.kobj, au_attr_group);
 
101
        if (unlikely(err))
 
102
                kset_unregister(&au_kset);
 
103
 
 
104
 out:
 
105
        AuTraceErr(err);
 
106
        return err;
 
107
}