~ubuntu-branches/ubuntu/raring/aufs/raring

« back to all changes in this revision

Viewing changes to fs/aufs25/module.c

  • Committer: Bazaar Package Importer
  • Author(s): Julian Andres Klode
  • Date: 2008-05-06 18:35:50 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: james.westby@ubuntu.com-20080506183550-7y7mrzkzkh2tjlfu
Tags: upstream-0+20080506
ImportĀ upstreamĀ versionĀ 0+20080506

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (C) 2007 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
 * module global variables and operations
 
21
 *
 
22
 * $Id: module.c,v 1.3 2008/04/28 03:02:06 sfjro Exp $
 
23
 */
 
24
 
 
25
#include <linux/module.h>
 
26
#include "aufs.h"
 
27
 
 
28
/* ---------------------------------------------------------------------- */
 
29
 
 
30
/*
 
31
 * aufs caches
 
32
 */
 
33
struct kmem_cache *au_cachep[AuCache_Last];
 
34
static int __init create_cache(void)
 
35
{
 
36
        au_cachep[AuCache_DINFO] = AuCache(au_dinfo);
 
37
        if (au_cachep[AuCache_DINFO])
 
38
                au_cachep[AuCache_ICNTNR] = AuCache(aufs_icntnr);
 
39
        if (au_cachep[AuCache_ICNTNR])
 
40
                au_cachep[AuCache_FINFO] = AuCache(au_finfo);
 
41
        //au_cachep[AuCache_FINFO] = NULL;
 
42
        if (au_cachep[AuCache_FINFO])
 
43
                au_cachep[AuCache_VDIR] = AuCache(au_vdir);
 
44
        if (au_cachep[AuCache_VDIR])
 
45
                au_cachep[AuCache_DEHSTR] = AuCache(au_vdir_dehstr);
 
46
        if (au_cachep[AuCache_DEHSTR])
 
47
                return 0;
 
48
 
 
49
        return -ENOMEM;
 
50
}
 
51
 
 
52
static void destroy_cache(void)
 
53
{
 
54
        int i;
 
55
        for (i = 0; i < AuCache_Last; i++)
 
56
                if (au_cachep[i]) {
 
57
                        kmem_cache_destroy(au_cachep[i]);
 
58
                        au_cachep[i] = NULL;
 
59
                }
 
60
}
 
61
 
 
62
/* ---------------------------------------------------------------------- */
 
63
 
 
64
char au_esc_chars[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
 
65
int au_dir_roflags;
 
66
 
 
67
/*
 
68
 * functions for module interface.
 
69
 */
 
70
MODULE_LICENSE("GPL");
 
71
MODULE_AUTHOR("Junjiro Okajima");
 
72
MODULE_DESCRIPTION(AUFS_NAME " -- Another unionfs");
 
73
MODULE_VERSION(AUFS_VERSION);
 
74
 
 
75
/* it should be 'byte', but param_set_byte() prints it by "%c" */
 
76
short aufs_nwkq = AUFS_NWKQ_DEF;
 
77
MODULE_PARM_DESC(nwkq, "the number of workqueue thread, " AUFS_WKQ_NAME);
 
78
module_param_named(nwkq, aufs_nwkq, short, S_IRUGO);
 
79
 
 
80
int sysaufs_brs;
 
81
MODULE_PARM_DESC(brs, "use <sysfs>/fs/aufs/sbi_*/brN");
 
82
module_param_named(brs, sysaufs_brs, int, S_IRUGO);
 
83
 
 
84
/* ---------------------------------------------------------------------- */
 
85
 
 
86
static int __init aufs_init(void)
 
87
{
 
88
        int err, i;
 
89
        char *p;
 
90
 
 
91
        au_debug_init();
 
92
 
 
93
        p = au_esc_chars;
 
94
        for (i = 1; i <= ' '; i++)
 
95
                *p++ = i;
 
96
        *p++ = '\\';
 
97
        *p++ = '\x7f';
 
98
        *p = 0;
 
99
 
 
100
        au_dir_roflags = au_file_roflags(O_DIRECTORY | O_LARGEFILE);
 
101
 
 
102
        err = -EINVAL;
 
103
        if (unlikely(aufs_nwkq <= 0))
 
104
                goto out;
 
105
 
 
106
        err = sysaufs_init();
 
107
        if (unlikely(err))
 
108
                goto out;
 
109
        err = au_wkq_init();
 
110
        if (unlikely(err))
 
111
                goto out_sysaufs;
 
112
        err = au_inotify_init();
 
113
        if (unlikely(err))
 
114
                goto out_wkq;
 
115
        err = au_sysrq_init();
 
116
        if (unlikely(err))
 
117
                goto out_inotify;
 
118
 
 
119
        err = create_cache();
 
120
        if (unlikely(err))
 
121
                goto out_sysrq;
 
122
 
 
123
        err = register_filesystem(&aufs_fs_type);
 
124
        if (unlikely(err))
 
125
                goto out_cache;
 
126
        pr_info(AUFS_NAME " " AUFS_VERSION "\n");
 
127
        return 0; /* success */
 
128
 
 
129
 out_cache:
 
130
        destroy_cache();
 
131
 out_sysrq:
 
132
        au_sysrq_fin();
 
133
 out_inotify:
 
134
        au_inotify_fin();
 
135
 out_wkq:
 
136
        au_wkq_fin();
 
137
 out_sysaufs:
 
138
        sysaufs_fin();
 
139
 out:
 
140
        AuTraceErr(err);
 
141
        return err;
 
142
}
 
143
 
 
144
static void __exit aufs_exit(void)
 
145
{
 
146
        unregister_filesystem(&aufs_fs_type);
 
147
        destroy_cache();
 
148
 
 
149
        au_sysrq_fin();
 
150
        au_inotify_fin();
 
151
        au_wkq_fin();
 
152
        sysaufs_fin();
 
153
}
 
154
 
 
155
module_init(aufs_init);
 
156
module_exit(aufs_exit);
 
157
 
 
158
/* ---------------------------------------------------------------------- */
 
159
 
 
160
/* fake Kconfig */
 
161
#if 1
 
162
 
 
163
#ifdef CONFIG_AUFS_HINOTIFY
 
164
#ifndef CONFIG_INOTIFY
 
165
#error enable CONFIG_INOTIFY to use CONFIG_AUFS_HINOTIFY.
 
166
#endif
 
167
#endif /* CONFIG_AUFS_HINOTIFY */
 
168
 
 
169
#if AUFS_BRANCH_MAX > 511 && PAGE_SIZE > 4096
 
170
#warning pagesize is larger than 4kb, \
 
171
        CONFIG_AUFS_BRANCH_MAX_511 or smaller is recommended.
 
172
#endif
 
173
 
 
174
#ifdef CONFIG_AUFS_STAT
 
175
#ifndef CONFIG_SYSFS
 
176
#error CONFIG_AUFS_STAT requires CONFIG_SYSFS.
 
177
#endif
 
178
#endif /* CONFIG_AUFS_STAT */
 
179
 
 
180
#ifdef CONFIG_AUFS_SYSAUFS
 
181
#warning CONFIG_AUFS_SYSAUFS is unnecessary for linux-2.6.25 and later.
 
182
#endif
 
183
 
 
184
#ifdef CONFIG_AUFS_EXPORT
 
185
#if !defined(CONFIG_EXPORTFS) && !defined(CONFIG_EXPORTFS_MODULE)
 
186
#error CONFIG_AUFS_EXPORT requires CONFIG_EXPORTFS
 
187
#endif
 
188
#if defined(CONFIG_EXPORTFS_MODULE) && defined(CONFIG_AUFS)
 
189
#error need CONFIG_EXPORTFS = y to link aufs statically with CONFIG_AUFS_EXPORT
 
190
#endif
 
191
#endif /* CONFIG_AUFS_EXPORT */
 
192
 
 
193
#ifdef CONFIG_AUFS_SEC_PERM_PATCH
 
194
#ifndef CONFIG_SECURITY
 
195
#warning CONFIG_AUFS_SEC_PERM_PATCH is unnecessary since CONFIG_SECURITY is disabled.
 
196
#endif
 
197
#ifdef CONFIG_AUFS
 
198
#warning CONFIG_AUFS_SEC_PERM_PATCH is unnecessary since CONFIG_AUFS is not a module.
 
199
#endif
 
200
#endif
 
201
 
 
202
#ifdef CONFIG_AUFS_PUT_FILP_PATCH
 
203
#if !defined(CONFIG_NFS_FS) && !defined(CONFIG_NFS_FS_MODULE)
 
204
#warning CONFIG_AUFS_PUT_FILP_PATCH is unnecessary since CONFIG_NFS_FS is disabled.
 
205
#endif
 
206
#ifdef CONFIG_AUFS
 
207
#warning CONFIG_AUFS_PUT_FILP_PATCH is unnecessary since CONFIG_AUFS is not a module.
 
208
#endif
 
209
#ifdef CONFIG_AUFS_FAKE_DM
 
210
#error CONFIG_AUFS_FAKE_DM must be disabled for CONFIG_AUFS_PUT_FILP_PATCH.
 
211
#endif
 
212
#endif /* CONFIG_AUFS_PUT_FILP_PATCH */
 
213
 
 
214
#ifdef CONFIG_AUFS_LHASH_PATCH
 
215
#if !defined(CONFIG_NFS_FS) && !defined(CONFIG_NFS_FS_MODULE)
 
216
#warning CONFIG_AUFS_LHASH_PATCH is unnecessary since CONFIG_NFS_FS is disabled.
 
217
#endif
 
218
#ifdef CONFIG_AUFS_FAKE_DM
 
219
#error CONFIG_AUFS_FAKE_DM must be disabled for CONFIG_AUFS_LHASH_PATCH.
 
220
#endif
 
221
#endif
 
222
 
 
223
#ifdef CONFIG_AUFS_KSIZE_PATCH
 
224
#warning CONFIG_AUFS_KSIZE_PATCH is unnecessary for linux-2.6.22 and later.
 
225
#endif
 
226
 
 
227
#ifdef CONFIG_AUFS_WORKAROUND_FUSE
 
228
#if !defined(CONFIG_FUSE_FS) && !defined(CONFIG_FUSE_FS_MODULE)
 
229
#warning CONFIG_AUFS_WORKAROUND_FUSE is enabled while FUSE is disabled.
 
230
#endif
 
231
#endif
 
232
 
 
233
#ifdef CONFIG_DEBUG_PROVE_LOCKING
 
234
#if MAX_LOCKDEP_SUBCLASSES < AuLsc_I_End
 
235
#warning lockdep will not work since aufs uses deeper locks.
 
236
#endif
 
237
#endif
 
238
 
 
239
#ifdef CONFIG_AUFS_COMPAT
 
240
#warning CONFIG_AUFS_COMPAT will be removed in the near future.
 
241
#endif
 
242
 
 
243
#endif