]>
git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blob - fs/aufs/module.c
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2005-2021 Junjiro R. Okajima
5 * This program, aufs is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * module global variables and operations
23 #include <linux/module.h>
24 #include <linux/seq_file.h>
27 /* shrinkable realloc */
28 void *au_krealloc(void *p
, unsigned int new_sz
, gfp_t gfp
, int may_shrink
)
46 diff
= au_kmidx_sub(sz
, new_sz
);
53 p
= krealloc(p
, new_sz
, gfp
);
54 else if (new_sz
< sz
&& may_shrink
) {
58 q
= kmalloc(new_sz
, gfp
);
73 void *au_kzrealloc(void *p
, unsigned int nused
, unsigned int new_sz
, gfp_t gfp
,
76 p
= au_krealloc(p
, new_sz
, gfp
, may_shrink
);
77 if (p
&& new_sz
> nused
)
78 memset(p
+ nused
, 0, new_sz
- nused
);
82 /* ---------------------------------------------------------------------- */
86 struct kmem_cache
*au_cache
[AuCache_Last
];
88 static void au_cache_fin(void)
93 * Make sure all delayed rcu free inodes are flushed before we
98 /* excluding AuCache_HNOTIFY */
99 BUILD_BUG_ON(AuCache_HNOTIFY
+ 1 != AuCache_Last
);
100 for (i
= 0; i
< AuCache_HNOTIFY
; i
++) {
101 kmem_cache_destroy(au_cache
[i
]);
106 static int __init
au_cache_init(void)
108 au_cache
[AuCache_DINFO
] = AuCacheCtor(au_dinfo
, au_di_init_once
);
109 if (au_cache
[AuCache_DINFO
])
110 /* SLAB_DESTROY_BY_RCU */
111 au_cache
[AuCache_ICNTNR
] = AuCacheCtor(au_icntnr
,
112 au_icntnr_init_once
);
113 if (au_cache
[AuCache_ICNTNR
])
114 au_cache
[AuCache_FINFO
] = AuCacheCtor(au_finfo
,
116 if (au_cache
[AuCache_FINFO
])
117 au_cache
[AuCache_VDIR
] = AuCache(au_vdir
);
118 if (au_cache
[AuCache_VDIR
])
119 au_cache
[AuCache_DEHSTR
] = AuCache(au_vdir_dehstr
);
120 if (au_cache
[AuCache_DEHSTR
])
127 /* ---------------------------------------------------------------------- */
131 #ifdef CONFIG_AUFS_SBILIST
133 * iterate_supers_type() doesn't protect us from
134 * remounting (branch management)
136 struct hlist_bl_head au_sbilist
;
140 * functions for module interface.
142 MODULE_LICENSE("GPL");
143 /* MODULE_LICENSE("GPL v2"); */
144 MODULE_AUTHOR("Junjiro R. Okajima <aufs-users@lists.sourceforge.net>");
145 MODULE_DESCRIPTION(AUFS_NAME
146 " -- Advanced multi layered unification filesystem");
147 MODULE_VERSION(AUFS_VERSION
);
148 MODULE_ALIAS_FS(AUFS_NAME
);
150 /* this module parameter has no meaning when SYSFS is disabled */
152 MODULE_PARM_DESC(brs
, "use <sysfs>/fs/aufs/si_*/brN");
153 module_param_named(brs
, sysaufs_brs
, int, 0444);
155 /* this module parameter has no meaning when USER_NS is disabled */
157 MODULE_PARM_DESC(allow_userns
, "allow unprivileged to mount under userns");
158 module_param_named(allow_userns
, au_userns
, bool, 0444);
160 /* ---------------------------------------------------------------------- */
162 static char au_esc_chars
[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */
164 int au_seq_path(struct seq_file
*seq
, struct path
*path
)
168 err
= seq_path(seq
, path
, au_esc_chars
);
177 /* ---------------------------------------------------------------------- */
179 static int __init
aufs_init(void)
185 for (i
= 1; i
<= ' '; i
++)
191 au_dir_roflags
= au_file_roflags(O_DIRECTORY
| O_LARGEFILE
);
193 memcpy(aufs_iop_nogetattr
, aufs_iop
, sizeof(aufs_iop
));
194 for (i
= 0; i
< AuIop_Last
; i
++)
195 aufs_iop_nogetattr
[i
].getattr
= NULL
;
197 memset(au_cache
, 0, sizeof(au_cache
)); /* including hnotify */
203 err
= sysaufs_init();
206 err
= dbgaufs_init();
209 err
= au_procfs_init();
215 err
= au_loopback_init();
218 err
= au_hnotify_init();
221 err
= au_sysrq_init();
224 err
= au_cache_init();
228 aufs_fs_type
.fs_flags
|= au_userns
? FS_USERNS_MOUNT
: 0;
229 err
= register_filesystem(&aufs_fs_type
);
233 /* since we define pr_fmt, call printk directly */
234 printk(KERN_INFO AUFS_NAME
" " AUFS_VERSION
"\n");
235 goto out
; /* success */
258 static void __exit
aufs_exit(void)
260 unregister_filesystem(&aufs_fs_type
);
272 module_init(aufs_init
);
273 module_exit(aufs_exit
);