]>
git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - fs/aufs/module.c
3ca7c705b2dd5dcde8e109bca0070bcf343f1d2f
2 * Copyright (C) 2005-2017 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, see <http://www.gnu.org/licenses/>.
19 * module global variables and operations
22 #include <linux/module.h>
23 #include <linux/seq_file.h>
26 /* shrinkable realloc */
27 void *au_krealloc(void *p
, unsigned int new_sz
, gfp_t gfp
, int may_shrink
)
45 diff
= au_kmidx_sub(sz
, new_sz
);
52 p
= krealloc(p
, new_sz
, gfp
);
53 else if (new_sz
< sz
&& may_shrink
) {
57 q
= kmalloc(new_sz
, gfp
);
72 void *au_kzrealloc(void *p
, unsigned int nused
, unsigned int new_sz
, gfp_t gfp
,
75 p
= au_krealloc(p
, new_sz
, gfp
, may_shrink
);
76 if (p
&& new_sz
> nused
)
77 memset(p
+ nused
, 0, new_sz
- nused
);
81 /* ---------------------------------------------------------------------- */
85 struct kmem_cache
*au_cache
[AuCache_Last
];
87 static void au_cache_fin(void)
92 * Make sure all delayed rcu free inodes are flushed before we
97 /* excluding AuCache_HNOTIFY */
98 BUILD_BUG_ON(AuCache_HNOTIFY
+ 1 != AuCache_Last
);
99 for (i
= 0; i
< AuCache_HNOTIFY
; i
++) {
100 kmem_cache_destroy(au_cache
[i
]);
105 static int __init
au_cache_init(void)
107 au_cache
[AuCache_DINFO
] = AuCacheCtor(au_dinfo
, au_di_init_once
);
108 if (au_cache
[AuCache_DINFO
])
109 /* SLAB_DESTROY_BY_RCU */
110 au_cache
[AuCache_ICNTNR
] = AuCacheCtor(au_icntnr
,
111 au_icntnr_init_once
);
112 if (au_cache
[AuCache_ICNTNR
])
113 au_cache
[AuCache_FINFO
] = AuCacheCtor(au_finfo
,
115 if (au_cache
[AuCache_FINFO
])
116 au_cache
[AuCache_VDIR
] = AuCache(au_vdir
);
117 if (au_cache
[AuCache_VDIR
])
118 au_cache
[AuCache_DEHSTR
] = AuCache(au_vdir_dehstr
);
119 if (au_cache
[AuCache_DEHSTR
])
126 /* ---------------------------------------------------------------------- */
130 #ifdef CONFIG_AUFS_SBILIST
132 * iterate_supers_type() doesn't protect us from
133 * remounting (branch management)
135 struct au_sphlhead au_sbilist
;
139 * functions for module interface.
141 MODULE_LICENSE("GPL");
142 /* MODULE_LICENSE("GPL v2"); */
143 MODULE_AUTHOR("Junjiro R. Okajima <aufs-users@lists.sourceforge.net>");
144 MODULE_DESCRIPTION(AUFS_NAME
145 " -- Advanced multi layered unification filesystem");
146 MODULE_VERSION(AUFS_VERSION
);
147 MODULE_ALIAS_FS(AUFS_NAME
);
149 /* this module parameter has no meaning when SYSFS is disabled */
151 MODULE_PARM_DESC(brs
, "use <sysfs>/fs/aufs/si_*/brN");
152 module_param_named(brs
, sysaufs_brs
, int, S_IRUGO
);
154 /* this module parameter has no meaning when USER_NS is disabled */
156 MODULE_PARM_DESC(allow_userns
, "allow unprivileged to mount under userns");
157 module_param_named(allow_userns
, au_userns
, bool, S_IRUGO
);
159 /* ---------------------------------------------------------------------- */
161 static char au_esc_chars
[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
163 int au_seq_path(struct seq_file
*seq
, struct path
*path
)
167 err
= seq_path(seq
, path
, au_esc_chars
);
176 /* ---------------------------------------------------------------------- */
178 static int __init
aufs_init(void)
184 for (i
= 1; i
<= ' '; i
++)
190 au_dir_roflags
= au_file_roflags(O_DIRECTORY
| O_LARGEFILE
);
192 memcpy(aufs_iop_nogetattr
, aufs_iop
, sizeof(aufs_iop
));
193 for (i
= 0; i
< AuIop_Last
; i
++)
194 aufs_iop_nogetattr
[i
].getattr
= NULL
;
196 memset(au_cache
, 0, sizeof(au_cache
)); /* including hnotify */
202 err
= sysaufs_init();
205 err
= au_procfs_init();
211 err
= au_loopback_init();
214 err
= au_hnotify_init();
217 err
= au_sysrq_init();
220 err
= au_cache_init();
224 aufs_fs_type
.fs_flags
|= au_userns
? FS_USERNS_MOUNT
: 0;
225 err
= register_filesystem(&aufs_fs_type
);
229 /* since we define pr_fmt, call printk directly */
230 printk(KERN_INFO AUFS_NAME
" " AUFS_VERSION
"\n");
231 goto out
; /* success */
252 static void __exit
aufs_exit(void)
254 unregister_filesystem(&aufs_fs_type
);
265 module_init(aufs_init
);
266 module_exit(aufs_exit
);