blob: 27ec726e7a464046e865a9c4f35afa5a727dffbb [file] [log] [blame]
Daniel Campello35c9e242015-07-20 16:23:50 -07001/*
2 * fs/sdcardfs/main.c
3 *
4 * Copyright (c) 2013 Samsung Electronics Co. Ltd
5 * Authors: Daeho Jeong, Woojoong Lee, Seunghwan Hyun,
6 * Sunghwan Yun, Sungjong Seo
7 *
8 * This program has been developed as a stackable file system based on
9 * the WrapFS which written by
10 *
11 * Copyright (c) 1998-2011 Erez Zadok
12 * Copyright (c) 2009 Shrikar Archak
13 * Copyright (c) 2003-2011 Stony Brook University
14 * Copyright (c) 2003-2011 The Research Foundation of SUNY
15 *
16 * This file is dual licensed. It may be redistributed and/or modified
17 * under the terms of the Apache 2.0 License OR version 2 of the GNU
18 * General Public License.
19 */
20
21#include "sdcardfs.h"
22#include <linux/module.h>
23#include <linux/types.h>
24#include <linux/parser.h>
25
26enum {
Daniel Rosenberg497ac902016-02-03 21:08:21 -080027 Opt_fsuid,
28 Opt_fsgid,
Daniel Campello35c9e242015-07-20 16:23:50 -070029 Opt_gid,
Daniel Campello35c9e242015-07-20 16:23:50 -070030 Opt_debug,
Daniel Rosenberg497ac902016-02-03 21:08:21 -080031 Opt_mask,
Daniel Rosenbergd64126c2017-03-16 19:33:35 -070032 Opt_multiuser,
Daniel Rosenberg497ac902016-02-03 21:08:21 -080033 Opt_userid,
Daniel Campello35c9e242015-07-20 16:23:50 -070034 Opt_reserved_mb,
Daniel Rosenberg7d10e432017-07-19 17:25:07 -070035 Opt_gid_derivation,
Daniel Rosenberg173c52e2018-01-02 14:44:49 -080036 Opt_default_normal,
Daniel Campello35c9e242015-07-20 16:23:50 -070037 Opt_err,
38};
39
40static const match_table_t sdcardfs_tokens = {
Daniel Rosenberg497ac902016-02-03 21:08:21 -080041 {Opt_fsuid, "fsuid=%u"},
42 {Opt_fsgid, "fsgid=%u"},
Daniel Campello35c9e242015-07-20 16:23:50 -070043 {Opt_gid, "gid=%u"},
Daniel Campello35c9e242015-07-20 16:23:50 -070044 {Opt_debug, "debug"},
Daniel Rosenberg497ac902016-02-03 21:08:21 -080045 {Opt_mask, "mask=%u"},
46 {Opt_userid, "userid=%d"},
47 {Opt_multiuser, "multiuser"},
Daniel Rosenberg7d10e432017-07-19 17:25:07 -070048 {Opt_gid_derivation, "derive_gid"},
Daniel Rosenberg173c52e2018-01-02 14:44:49 -080049 {Opt_default_normal, "default_normal"},
Daniel Campello35c9e242015-07-20 16:23:50 -070050 {Opt_reserved_mb, "reserved_mb=%u"},
51 {Opt_err, NULL}
52};
53
54static int parse_options(struct super_block *sb, char *options, int silent,
Daniel Rosenberg317e7702016-10-26 17:36:05 -070055 int *debug, struct sdcardfs_vfsmount_options *vfsopts,
56 struct sdcardfs_mount_options *opts)
Daniel Campello35c9e242015-07-20 16:23:50 -070057{
58 char *p;
59 substring_t args[MAX_OPT_ARGS];
60 int option;
Daniel Campello35c9e242015-07-20 16:23:50 -070061
62 /* by default, we use AID_MEDIA_RW as uid, gid */
63 opts->fs_low_uid = AID_MEDIA_RW;
64 opts->fs_low_gid = AID_MEDIA_RW;
Daniel Rosenberg317e7702016-10-26 17:36:05 -070065 vfsopts->mask = 0;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080066 opts->multiuser = false;
67 opts->fs_user_id = 0;
Daniel Rosenberg317e7702016-10-26 17:36:05 -070068 vfsopts->gid = 0;
Daniel Campello35c9e242015-07-20 16:23:50 -070069 /* by default, 0MB is reserved */
70 opts->reserved_mb = 0;
Daniel Rosenberg7d10e432017-07-19 17:25:07 -070071 /* by default, gid derivation is off */
72 opts->gid_derivation = false;
Daniel Rosenberge12a9c42018-01-18 16:17:16 -080073 opts->default_normal = false;
Daniel Campello35c9e242015-07-20 16:23:50 -070074
75 *debug = 0;
76
77 if (!options)
78 return 0;
79
80 while ((p = strsep(&options, ",")) != NULL) {
81 int token;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -070082
Daniel Campello35c9e242015-07-20 16:23:50 -070083 if (!*p)
84 continue;
85
86 token = match_token(p, sdcardfs_tokens, args);
87
88 switch (token) {
89 case Opt_debug:
90 *debug = 1;
91 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080092 case Opt_fsuid:
Daniel Campello35c9e242015-07-20 16:23:50 -070093 if (match_int(&args[0], &option))
94 return 0;
95 opts->fs_low_uid = option;
96 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080097 case Opt_fsgid:
Daniel Campello35c9e242015-07-20 16:23:50 -070098 if (match_int(&args[0], &option))
99 return 0;
100 opts->fs_low_gid = option;
101 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800102 case Opt_gid:
Daniel Campello35c9e242015-07-20 16:23:50 -0700103 if (match_int(&args[0], &option))
104 return 0;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700105 vfsopts->gid = option;
Daniel Campello35c9e242015-07-20 16:23:50 -0700106 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800107 case Opt_userid:
108 if (match_int(&args[0], &option))
109 return 0;
110 opts->fs_user_id = option;
Daniel Campello35c9e242015-07-20 16:23:50 -0700111 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800112 case Opt_mask:
113 if (match_int(&args[0], &option))
114 return 0;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700115 vfsopts->mask = option;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800116 break;
117 case Opt_multiuser:
118 opts->multiuser = true;
Daniel Campello35c9e242015-07-20 16:23:50 -0700119 break;
Daniel Campello35c9e242015-07-20 16:23:50 -0700120 case Opt_reserved_mb:
121 if (match_int(&args[0], &option))
122 return 0;
123 opts->reserved_mb = option;
124 break;
Daniel Rosenberg7d10e432017-07-19 17:25:07 -0700125 case Opt_gid_derivation:
126 opts->gid_derivation = true;
Daniel Rosenberg93babeb2017-09-08 17:20:06 -0700127 break;
Daniel Rosenberg173c52e2018-01-02 14:44:49 -0800128 case Opt_default_normal:
Daniel Rosenberge12a9c42018-01-18 16:17:16 -0800129 opts->default_normal = true;
Daniel Rosenberg14dbf602018-01-08 13:57:36 -0800130 break;
Daniel Campello35c9e242015-07-20 16:23:50 -0700131 /* unknown option */
132 default:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700133 if (!silent)
134 pr_err("Unrecognized mount option \"%s\" or missing value", p);
Daniel Campello35c9e242015-07-20 16:23:50 -0700135 return -EINVAL;
136 }
137 }
138
139 if (*debug) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700140 pr_info("sdcardfs : options - debug:%d\n", *debug);
141 pr_info("sdcardfs : options - uid:%d\n",
Daniel Campello35c9e242015-07-20 16:23:50 -0700142 opts->fs_low_uid);
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700143 pr_info("sdcardfs : options - gid:%d\n",
Daniel Campello35c9e242015-07-20 16:23:50 -0700144 opts->fs_low_gid);
145 }
146
147 return 0;
148}
149
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700150int parse_options_remount(struct super_block *sb, char *options, int silent,
151 struct sdcardfs_vfsmount_options *vfsopts)
152{
153 char *p;
154 substring_t args[MAX_OPT_ARGS];
155 int option;
156 int debug;
157
158 if (!options)
159 return 0;
160
161 while ((p = strsep(&options, ",")) != NULL) {
162 int token;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700163
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700164 if (!*p)
165 continue;
166
167 token = match_token(p, sdcardfs_tokens, args);
168
169 switch (token) {
170 case Opt_debug:
171 debug = 1;
172 break;
173 case Opt_gid:
174 if (match_int(&args[0], &option))
175 return 0;
176 vfsopts->gid = option;
177
178 break;
179 case Opt_mask:
180 if (match_int(&args[0], &option))
181 return 0;
182 vfsopts->mask = option;
183 break;
Daniel Rosenberg173c52e2018-01-02 14:44:49 -0800184 case Opt_default_normal:
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700185 case Opt_multiuser:
186 case Opt_userid:
187 case Opt_fsuid:
188 case Opt_fsgid:
189 case Opt_reserved_mb:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700190 pr_warn("Option \"%s\" can't be changed during remount\n", p);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700191 break;
192 /* unknown option */
193 default:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700194 if (!silent)
195 pr_err("Unrecognized mount option \"%s\" or missing value", p);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700196 return -EINVAL;
197 }
198 }
199
200 if (debug) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700201 pr_info("sdcardfs : options - debug:%d\n", debug);
202 pr_info("sdcardfs : options - gid:%d\n", vfsopts->gid);
203 pr_info("sdcardfs : options - mask:%d\n", vfsopts->mask);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700204 }
205
206 return 0;
207}
208
Daniel Campellod1d080c2015-07-20 16:27:37 -0700209#if 0
Daniel Campello35c9e242015-07-20 16:23:50 -0700210/*
211 * our custom d_alloc_root work-alike
212 *
213 * we can't use d_alloc_root if we want to use our own interpose function
214 * unchanged, so we simply call our own "fake" d_alloc_root
215 */
216static struct dentry *sdcardfs_d_alloc_root(struct super_block *sb)
217{
218 struct dentry *ret = NULL;
219
220 if (sb) {
221 static const struct qstr name = {
222 .name = "/",
223 .len = 1
224 };
225
226 ret = d_alloc(NULL, &name);
227 if (ret) {
228 d_set_d_op(ret, &sdcardfs_ci_dops);
229 ret->d_sb = sb;
230 ret->d_parent = ret;
231 }
232 }
233 return ret;
234}
Daniel Campellod1d080c2015-07-20 16:27:37 -0700235#endif
Daniel Campello35c9e242015-07-20 16:23:50 -0700236
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800237DEFINE_MUTEX(sdcardfs_super_list_lock);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800238EXPORT_SYMBOL_GPL(sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700239LIST_HEAD(sdcardfs_super_list);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800240EXPORT_SYMBOL_GPL(sdcardfs_super_list);
241
Daniel Campello35c9e242015-07-20 16:23:50 -0700242/*
243 * There is no need to lock the sdcardfs_super_info's rwsem as there is no
244 * way anyone can have a reference to the superblock at this point in time.
245 */
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700246static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
247 const char *dev_name, void *raw_data, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700248{
249 int err = 0;
250 int debug;
251 struct super_block *lower_sb;
252 struct path lower_path;
253 struct sdcardfs_sb_info *sb_info;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700254 struct sdcardfs_vfsmount_options *mnt_opt = mnt->data;
Daniel Campellod1d080c2015-07-20 16:27:37 -0700255 struct inode *inode;
Daniel Campello35c9e242015-07-20 16:23:50 -0700256
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700257 pr_info("sdcardfs version 2.0\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700258
259 if (!dev_name) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700260 pr_err("sdcardfs: read_super: missing dev_name argument\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700261 err = -EINVAL;
262 goto out;
263 }
264
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700265 pr_info("sdcardfs: dev_name -> %s\n", dev_name);
266 pr_info("sdcardfs: options -> %s\n", (char *)raw_data);
267 pr_info("sdcardfs: mnt -> %p\n", mnt);
Daniel Campello35c9e242015-07-20 16:23:50 -0700268
269 /* parse lower path */
270 err = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
271 &lower_path);
272 if (err) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700273 pr_err("sdcardfs: error accessing lower directory '%s'\n", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700274 goto out;
275 }
276
277 /* allocate superblock private data */
278 sb->s_fs_info = kzalloc(sizeof(struct sdcardfs_sb_info), GFP_KERNEL);
279 if (!SDCARDFS_SB(sb)) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700280 pr_crit("sdcardfs: read_super: out of memory\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700281 err = -ENOMEM;
282 goto out_free;
283 }
284
285 sb_info = sb->s_fs_info;
Daniel Campello35c9e242015-07-20 16:23:50 -0700286 /* parse options */
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700287 err = parse_options(sb, raw_data, silent, &debug, mnt_opt, &sb_info->options);
Daniel Campello35c9e242015-07-20 16:23:50 -0700288 if (err) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700289 pr_err("sdcardfs: invalid options\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700290 goto out_freesbi;
291 }
292
Daniel Campello35c9e242015-07-20 16:23:50 -0700293 /* set the lower superblock field of upper superblock */
294 lower_sb = lower_path.dentry->d_sb;
295 atomic_inc(&lower_sb->s_active);
296 sdcardfs_set_lower_super(sb, lower_sb);
297
Daniel Rosenberg99055912018-07-26 16:32:09 -0700298 sb->s_stack_depth = lower_sb->s_stack_depth + 1;
299 if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
300 pr_err("sdcardfs: maximum fs stacking depth exceeded\n");
301 err = -EINVAL;
302 goto out_sput;
303 }
304
Daniel Campello35c9e242015-07-20 16:23:50 -0700305 /* inherit maxbytes from lower file system */
306 sb->s_maxbytes = lower_sb->s_maxbytes;
307
308 /*
309 * Our c/m/atime granularity is 1 ns because we may stack on file
310 * systems whose granularity is as good.
311 */
312 sb->s_time_gran = 1;
313
314 sb->s_magic = SDCARDFS_SUPER_MAGIC;
315 sb->s_op = &sdcardfs_sops;
316
Daniel Campellod1d080c2015-07-20 16:27:37 -0700317 /* get a new inode and allocate our root dentry */
Daniel Rosenberg63d20762016-12-01 14:36:29 -0800318 inode = sdcardfs_iget(sb, d_inode(lower_path.dentry), 0);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700319 if (IS_ERR(inode)) {
320 err = PTR_ERR(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700321 goto out_sput;
322 }
Daniel Campellod1d080c2015-07-20 16:27:37 -0700323 sb->s_root = d_make_root(inode);
324 if (!sb->s_root) {
325 err = -ENOMEM;
Daniel Rosenberg8442aee2018-04-11 16:24:51 -0700326 goto out_sput;
Daniel Campellod1d080c2015-07-20 16:27:37 -0700327 }
328 d_set_d_op(sb->s_root, &sdcardfs_ci_dops);
Daniel Campello35c9e242015-07-20 16:23:50 -0700329
330 /* link the upper and lower dentries */
331 sb->s_root->d_fsdata = NULL;
332 err = new_dentry_private_data(sb->s_root);
333 if (err)
334 goto out_freeroot;
335
336 /* set the lower dentries for s_root */
337 sdcardfs_set_lower_path(sb->s_root, &lower_path);
338
Daniel Campellod1d080c2015-07-20 16:27:37 -0700339 /*
340 * No need to call interpose because we already have a positive
341 * dentry, which was instantiated by d_make_root. Just need to
342 * d_rehash it.
343 */
344 d_rehash(sb->s_root);
345
346 /* setup permission policy */
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800347 sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
348 mutex_lock(&sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700349 if (sb_info->options.multiuser) {
350 setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
Daniel Rosenberg47af77b2018-02-01 16:52:22 -0800351 sb_info->options.fs_user_id, AID_ROOT);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800352 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800353 } else {
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700354 setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
Daniel Rosenberg47af77b2018-02-01 16:52:22 -0800355 sb_info->options.fs_user_id, AID_ROOT);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800356 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700357 }
Daniel Rosenberg90219272016-10-26 20:27:20 -0700358 fixup_tmp_permissions(d_inode(sb->s_root));
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800359 sb_info->sb = sb;
360 list_add(&sb_info->list, &sdcardfs_super_list);
361 mutex_unlock(&sdcardfs_super_list_lock);
Daniel Campello35c9e242015-07-20 16:23:50 -0700362
Daniel Campellod1d080c2015-07-20 16:27:37 -0700363 if (!silent)
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700364 pr_info("sdcardfs: mounted on top of %s type %s\n",
Daniel Campellod1d080c2015-07-20 16:27:37 -0700365 dev_name, lower_sb->s_type->name);
366 goto out; /* all is well */
367
368 /* no longer needed: free_dentry_private_data(sb->s_root); */
Daniel Campello35c9e242015-07-20 16:23:50 -0700369out_freeroot:
370 dput(sb->s_root);
Daniel Rosenberg132f0972018-04-11 18:39:43 -0700371 sb->s_root = NULL;
Daniel Campello35c9e242015-07-20 16:23:50 -0700372out_sput:
373 /* drop refs we took earlier */
374 atomic_dec(&lower_sb->s_active);
Daniel Campello35c9e242015-07-20 16:23:50 -0700375out_freesbi:
376 kfree(SDCARDFS_SB(sb));
377 sb->s_fs_info = NULL;
378out_free:
379 path_put(&lower_path);
380
381out:
382 return err;
383}
384
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800385struct sdcardfs_mount_private {
386 struct vfsmount *mnt;
387 const char *dev_name;
388 void *raw_data;
389};
Daniel Campello35c9e242015-07-20 16:23:50 -0700390
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800391static int __sdcardfs_fill_super(
392 struct super_block *sb,
393 void *_priv, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700394{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800395 struct sdcardfs_mount_private *priv = _priv;
Daniel Campello35c9e242015-07-20 16:23:50 -0700396
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800397 return sdcardfs_read_super(priv->mnt,
398 sb, priv->dev_name, priv->raw_data, silent);
Daniel Campello35c9e242015-07-20 16:23:50 -0700399}
400
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700401static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
402 struct file_system_type *fs_type, int flags,
Daniel Campello35c9e242015-07-20 16:23:50 -0700403 const char *dev_name, void *raw_data)
404{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800405 struct sdcardfs_mount_private priv = {
406 .mnt = mnt,
407 .dev_name = dev_name,
408 .raw_data = raw_data
409 };
410
411 return mount_nodev(fs_type, flags,
412 &priv, __sdcardfs_fill_super);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700413}
414
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700415static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
416 int flags, const char *dev_name, void *raw_data)
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700417{
418 WARN(1, "sdcardfs does not support mount. Use mount2.\n");
419 return ERR_PTR(-EINVAL);
420}
421
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700422void *sdcardfs_alloc_mnt_data(void)
423{
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700424 return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
Daniel Campello35c9e242015-07-20 16:23:50 -0700425}
426
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700427void sdcardfs_kill_sb(struct super_block *sb)
428{
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800429 struct sdcardfs_sb_info *sbi;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700430
Daniel Rosenberga0838172018-04-11 16:19:10 -0700431 if (sb->s_magic == SDCARDFS_SUPER_MAGIC && sb->s_fs_info) {
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800432 sbi = SDCARDFS_SB(sb);
433 mutex_lock(&sdcardfs_super_list_lock);
434 list_del(&sbi->list);
435 mutex_unlock(&sdcardfs_super_list_lock);
436 }
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800437 kill_anon_super(sb);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800438}
439
Daniel Campello35c9e242015-07-20 16:23:50 -0700440static struct file_system_type sdcardfs_fs_type = {
441 .owner = THIS_MODULE,
442 .name = SDCARDFS_NAME,
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700443 .mount = sdcardfs_mount_wrn,
444 .mount2 = sdcardfs_mount,
445 .alloc_mnt_data = sdcardfs_alloc_mnt_data,
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800446 .kill_sb = sdcardfs_kill_sb,
Daniel Campellod1d080c2015-07-20 16:27:37 -0700447 .fs_flags = 0,
Daniel Campello35c9e242015-07-20 16:23:50 -0700448};
Daniel Rosenberg35ba5f62017-03-09 20:59:18 -0800449MODULE_ALIAS_FS(SDCARDFS_NAME);
Daniel Campello35c9e242015-07-20 16:23:50 -0700450
451static int __init init_sdcardfs_fs(void)
452{
453 int err;
454
455 pr_info("Registering sdcardfs " SDCARDFS_VERSION "\n");
456
457 err = sdcardfs_init_inode_cache();
458 if (err)
459 goto out;
460 err = sdcardfs_init_dentry_cache();
461 if (err)
462 goto out;
463 err = packagelist_init();
464 if (err)
465 goto out;
466 err = register_filesystem(&sdcardfs_fs_type);
467out:
468 if (err) {
469 sdcardfs_destroy_inode_cache();
470 sdcardfs_destroy_dentry_cache();
471 packagelist_exit();
472 }
473 return err;
474}
475
476static void __exit exit_sdcardfs_fs(void)
477{
478 sdcardfs_destroy_inode_cache();
479 sdcardfs_destroy_dentry_cache();
480 packagelist_exit();
481 unregister_filesystem(&sdcardfs_fs_type);
482 pr_info("Completed sdcardfs module unload\n");
483}
484
Daniel Rosenberg75665df2017-03-09 20:56:05 -0800485/* Original wrapfs authors */
486MODULE_AUTHOR("Erez Zadok, Filesystems and Storage Lab, Stony Brook University (http://www.fsl.cs.sunysb.edu/)");
487
488/* Original sdcardfs authors */
489MODULE_AUTHOR("Woojoong Lee, Daeho Jeong, Kitae Lee, Yeongjin Gil System Memory Lab., Samsung Electronics");
490
491/* Current maintainer */
492MODULE_AUTHOR("Daniel Rosenberg, Google");
493MODULE_DESCRIPTION("Sdcardfs " SDCARDFS_VERSION);
Daniel Campello35c9e242015-07-20 16:23:50 -0700494MODULE_LICENSE("GPL");
495
496module_init(init_sdcardfs_fs);
497module_exit(exit_sdcardfs_fs);