2 * Copyright (C) 2005-2013 Junjiro R. 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 * module global variables and operations
23 #include <linux/module.h>
24 #include <linux/seq_file.h>
27 void *au_kzrealloc(void *p, unsigned int nused, unsigned int new_sz, gfp_t gfp)
32 p = krealloc(p, new_sz, gfp);
34 memset(p + nused, 0, new_sz - nused);
38 /* ---------------------------------------------------------------------- */
43 struct kmem_cache *au_cachep[AuCache_Last];
44 static int __init au_cache_init(void)
46 au_cachep[AuCache_DINFO] = AuCacheCtor(au_dinfo, au_di_init_once);
47 if (au_cachep[AuCache_DINFO])
48 /* SLAB_DESTROY_BY_RCU */
49 au_cachep[AuCache_ICNTNR] = AuCacheCtor(au_icntnr,
51 if (au_cachep[AuCache_ICNTNR])
52 au_cachep[AuCache_FINFO] = AuCacheCtor(au_finfo,
54 if (au_cachep[AuCache_FINFO])
55 au_cachep[AuCache_VDIR] = AuCache(au_vdir);
56 if (au_cachep[AuCache_VDIR])
57 au_cachep[AuCache_DEHSTR] = AuCache(au_vdir_dehstr);
58 if (au_cachep[AuCache_DEHSTR])
64 static void au_cache_fin(void)
68 /* excluding AuCache_HNOTIFY */
69 BUILD_BUG_ON(AuCache_HNOTIFY + 1 != AuCache_Last);
70 for (i = 0; i < AuCache_HNOTIFY; i++)
72 kmem_cache_destroy(au_cachep[i]);
77 /* ---------------------------------------------------------------------- */
81 #ifdef CONFIG_AUFS_SBILIST
83 * iterate_supers_type() doesn't protect us from
84 * remounting (branch management)
86 struct au_splhead au_sbilist;
89 struct lock_class_key au_lc_key[AuLcKey_Last];
92 * functions for module interface.
94 MODULE_LICENSE("GPL");
95 /* MODULE_LICENSE("GPL v2"); */
96 MODULE_AUTHOR("Junjiro R. Okajima <aufs-users@lists.sourceforge.net>");
97 MODULE_DESCRIPTION(AUFS_NAME
98 " -- Advanced multi layered unification filesystem");
99 MODULE_VERSION(AUFS_VERSION);
101 /* this module parameter has no meaning when SYSFS is disabled */
103 MODULE_PARM_DESC(brs, "use <sysfs>/fs/aufs/si_*/brN");
104 module_param_named(brs, sysaufs_brs, int, S_IRUGO);
106 /* ---------------------------------------------------------------------- */
108 static char au_esc_chars[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
110 int au_seq_path(struct seq_file *seq, struct path *path)
112 return seq_path(seq, path, au_esc_chars);
115 /* ---------------------------------------------------------------------- */
117 static int __init aufs_init(void)
123 for (i = 1; i <= ' '; i++)
129 au_dir_roflags = au_file_roflags(O_DIRECTORY | O_LARGEFILE);
135 err = sysaufs_init();
138 err = au_procfs_init();
144 err = au_loopback_init();
147 err = au_hnotify_init();
150 err = au_sysrq_init();
153 err = au_cache_init();
156 err = register_filesystem(&aufs_fs_type);
159 /* since we define pr_fmt, call printk directly */
160 printk(KERN_INFO AUFS_NAME " " AUFS_VERSION "\n");
161 goto out; /* success */
182 static void __exit aufs_exit(void)
184 unregister_filesystem(&aufs_fs_type);
195 module_init(aufs_init);
196 module_exit(aufs_exit);