blob: 0a2b5167e9a2e5562b7af6e3642140c20816609b [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 Campello35c9e242015-07-20 16:23:50 -070036 Opt_err,
37};
38
39static const match_table_t sdcardfs_tokens = {
Daniel Rosenberg497ac902016-02-03 21:08:21 -080040 {Opt_fsuid, "fsuid=%u"},
41 {Opt_fsgid, "fsgid=%u"},
Daniel Campello35c9e242015-07-20 16:23:50 -070042 {Opt_gid, "gid=%u"},
Daniel Campello35c9e242015-07-20 16:23:50 -070043 {Opt_debug, "debug"},
Daniel Rosenberg497ac902016-02-03 21:08:21 -080044 {Opt_mask, "mask=%u"},
45 {Opt_userid, "userid=%d"},
46 {Opt_multiuser, "multiuser"},
Daniel Rosenberg7d10e432017-07-19 17:25:07 -070047 {Opt_gid_derivation, "derive_gid"},
Daniel Campello35c9e242015-07-20 16:23:50 -070048 {Opt_reserved_mb, "reserved_mb=%u"},
49 {Opt_err, NULL}
50};
51
52static int parse_options(struct super_block *sb, char *options, int silent,
Daniel Rosenberg317e7702016-10-26 17:36:05 -070053 int *debug, struct sdcardfs_vfsmount_options *vfsopts,
54 struct sdcardfs_mount_options *opts)
Daniel Campello35c9e242015-07-20 16:23:50 -070055{
56 char *p;
57 substring_t args[MAX_OPT_ARGS];
58 int option;
Daniel Campello35c9e242015-07-20 16:23:50 -070059
60 /* by default, we use AID_MEDIA_RW as uid, gid */
61 opts->fs_low_uid = AID_MEDIA_RW;
62 opts->fs_low_gid = AID_MEDIA_RW;
Daniel Rosenberg317e7702016-10-26 17:36:05 -070063 vfsopts->mask = 0;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080064 opts->multiuser = false;
65 opts->fs_user_id = 0;
Daniel Rosenberg317e7702016-10-26 17:36:05 -070066 vfsopts->gid = 0;
Daniel Campello35c9e242015-07-20 16:23:50 -070067 /* by default, 0MB is reserved */
68 opts->reserved_mb = 0;
Daniel Rosenberg7d10e432017-07-19 17:25:07 -070069 /* by default, gid derivation is off */
70 opts->gid_derivation = false;
Daniel Campello35c9e242015-07-20 16:23:50 -070071
72 *debug = 0;
73
74 if (!options)
75 return 0;
76
77 while ((p = strsep(&options, ",")) != NULL) {
78 int token;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -070079
Daniel Campello35c9e242015-07-20 16:23:50 -070080 if (!*p)
81 continue;
82
83 token = match_token(p, sdcardfs_tokens, args);
84
85 switch (token) {
86 case Opt_debug:
87 *debug = 1;
88 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080089 case Opt_fsuid:
Daniel Campello35c9e242015-07-20 16:23:50 -070090 if (match_int(&args[0], &option))
91 return 0;
92 opts->fs_low_uid = option;
93 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080094 case Opt_fsgid:
Daniel Campello35c9e242015-07-20 16:23:50 -070095 if (match_int(&args[0], &option))
96 return 0;
97 opts->fs_low_gid = option;
98 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -080099 case Opt_gid:
Daniel Campello35c9e242015-07-20 16:23:50 -0700100 if (match_int(&args[0], &option))
101 return 0;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700102 vfsopts->gid = option;
Daniel Campello35c9e242015-07-20 16:23:50 -0700103 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800104 case Opt_userid:
105 if (match_int(&args[0], &option))
106 return 0;
107 opts->fs_user_id = option;
Daniel Campello35c9e242015-07-20 16:23:50 -0700108 break;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800109 case Opt_mask:
110 if (match_int(&args[0], &option))
111 return 0;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700112 vfsopts->mask = option;
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800113 break;
114 case Opt_multiuser:
115 opts->multiuser = true;
Daniel Campello35c9e242015-07-20 16:23:50 -0700116 break;
Daniel Campello35c9e242015-07-20 16:23:50 -0700117 case Opt_reserved_mb:
118 if (match_int(&args[0], &option))
119 return 0;
120 opts->reserved_mb = option;
121 break;
Daniel Rosenberg7d10e432017-07-19 17:25:07 -0700122 case Opt_gid_derivation:
123 opts->gid_derivation = true;
Daniel Rosenberg93babeb2017-09-08 17:20:06 -0700124 break;
Daniel Campello35c9e242015-07-20 16:23:50 -0700125 /* unknown option */
126 default:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700127 if (!silent)
128 pr_err("Unrecognized mount option \"%s\" or missing value", p);
Daniel Campello35c9e242015-07-20 16:23:50 -0700129 return -EINVAL;
130 }
131 }
132
133 if (*debug) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700134 pr_info("sdcardfs : options - debug:%d\n", *debug);
135 pr_info("sdcardfs : options - uid:%d\n",
Daniel Campello35c9e242015-07-20 16:23:50 -0700136 opts->fs_low_uid);
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700137 pr_info("sdcardfs : options - gid:%d\n",
Daniel Campello35c9e242015-07-20 16:23:50 -0700138 opts->fs_low_gid);
139 }
140
141 return 0;
142}
143
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700144int parse_options_remount(struct super_block *sb, char *options, int silent,
145 struct sdcardfs_vfsmount_options *vfsopts)
146{
147 char *p;
148 substring_t args[MAX_OPT_ARGS];
149 int option;
150 int debug;
151
152 if (!options)
153 return 0;
154
155 while ((p = strsep(&options, ",")) != NULL) {
156 int token;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700157
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700158 if (!*p)
159 continue;
160
161 token = match_token(p, sdcardfs_tokens, args);
162
163 switch (token) {
164 case Opt_debug:
165 debug = 1;
166 break;
167 case Opt_gid:
168 if (match_int(&args[0], &option))
169 return 0;
170 vfsopts->gid = option;
171
172 break;
173 case Opt_mask:
174 if (match_int(&args[0], &option))
175 return 0;
176 vfsopts->mask = option;
177 break;
178 case Opt_multiuser:
179 case Opt_userid:
180 case Opt_fsuid:
181 case Opt_fsgid:
182 case Opt_reserved_mb:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700183 pr_warn("Option \"%s\" can't be changed during remount\n", p);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700184 break;
185 /* unknown option */
186 default:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700187 if (!silent)
188 pr_err("Unrecognized mount option \"%s\" or missing value", p);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700189 return -EINVAL;
190 }
191 }
192
193 if (debug) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700194 pr_info("sdcardfs : options - debug:%d\n", debug);
195 pr_info("sdcardfs : options - gid:%d\n", vfsopts->gid);
196 pr_info("sdcardfs : options - mask:%d\n", vfsopts->mask);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700197 }
198
199 return 0;
200}
201
Daniel Campellod1d080c2015-07-20 16:27:37 -0700202#if 0
Daniel Campello35c9e242015-07-20 16:23:50 -0700203/*
204 * our custom d_alloc_root work-alike
205 *
206 * we can't use d_alloc_root if we want to use our own interpose function
207 * unchanged, so we simply call our own "fake" d_alloc_root
208 */
209static struct dentry *sdcardfs_d_alloc_root(struct super_block *sb)
210{
211 struct dentry *ret = NULL;
212
213 if (sb) {
214 static const struct qstr name = {
215 .name = "/",
216 .len = 1
217 };
218
219 ret = d_alloc(NULL, &name);
220 if (ret) {
221 d_set_d_op(ret, &sdcardfs_ci_dops);
222 ret->d_sb = sb;
223 ret->d_parent = ret;
224 }
225 }
226 return ret;
227}
Daniel Campellod1d080c2015-07-20 16:27:37 -0700228#endif
Daniel Campello35c9e242015-07-20 16:23:50 -0700229
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800230DEFINE_MUTEX(sdcardfs_super_list_lock);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800231EXPORT_SYMBOL_GPL(sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700232LIST_HEAD(sdcardfs_super_list);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800233EXPORT_SYMBOL_GPL(sdcardfs_super_list);
234
Daniel Campello35c9e242015-07-20 16:23:50 -0700235/*
236 * There is no need to lock the sdcardfs_super_info's rwsem as there is no
237 * way anyone can have a reference to the superblock at this point in time.
238 */
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700239static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
240 const char *dev_name, void *raw_data, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700241{
242 int err = 0;
243 int debug;
244 struct super_block *lower_sb;
245 struct path lower_path;
246 struct sdcardfs_sb_info *sb_info;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700247 struct sdcardfs_vfsmount_options *mnt_opt = mnt->data;
Daniel Campellod1d080c2015-07-20 16:27:37 -0700248 struct inode *inode;
Daniel Campello35c9e242015-07-20 16:23:50 -0700249
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700250 pr_info("sdcardfs version 2.0\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700251
252 if (!dev_name) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700253 pr_err("sdcardfs: read_super: missing dev_name argument\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700254 err = -EINVAL;
255 goto out;
256 }
257
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700258 pr_info("sdcardfs: dev_name -> %s\n", dev_name);
259 pr_info("sdcardfs: options -> %s\n", (char *)raw_data);
260 pr_info("sdcardfs: mnt -> %p\n", mnt);
Daniel Campello35c9e242015-07-20 16:23:50 -0700261
262 /* parse lower path */
263 err = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
264 &lower_path);
265 if (err) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700266 pr_err("sdcardfs: error accessing lower directory '%s'\n", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700267 goto out;
268 }
269
270 /* allocate superblock private data */
271 sb->s_fs_info = kzalloc(sizeof(struct sdcardfs_sb_info), GFP_KERNEL);
272 if (!SDCARDFS_SB(sb)) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700273 pr_crit("sdcardfs: read_super: out of memory\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700274 err = -ENOMEM;
275 goto out_free;
276 }
277
278 sb_info = sb->s_fs_info;
Daniel Campello35c9e242015-07-20 16:23:50 -0700279 /* parse options */
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700280 err = parse_options(sb, raw_data, silent, &debug, mnt_opt, &sb_info->options);
Daniel Campello35c9e242015-07-20 16:23:50 -0700281 if (err) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700282 pr_err("sdcardfs: invalid options\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700283 goto out_freesbi;
284 }
285
Daniel Campello35c9e242015-07-20 16:23:50 -0700286 /* set the lower superblock field of upper superblock */
287 lower_sb = lower_path.dentry->d_sb;
288 atomic_inc(&lower_sb->s_active);
289 sdcardfs_set_lower_super(sb, lower_sb);
290
291 /* inherit maxbytes from lower file system */
292 sb->s_maxbytes = lower_sb->s_maxbytes;
293
294 /*
295 * Our c/m/atime granularity is 1 ns because we may stack on file
296 * systems whose granularity is as good.
297 */
298 sb->s_time_gran = 1;
299
300 sb->s_magic = SDCARDFS_SUPER_MAGIC;
301 sb->s_op = &sdcardfs_sops;
302
Daniel Campellod1d080c2015-07-20 16:27:37 -0700303 /* get a new inode and allocate our root dentry */
Daniel Rosenberg63d20762016-12-01 14:36:29 -0800304 inode = sdcardfs_iget(sb, d_inode(lower_path.dentry), 0);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700305 if (IS_ERR(inode)) {
306 err = PTR_ERR(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700307 goto out_sput;
308 }
Daniel Campellod1d080c2015-07-20 16:27:37 -0700309 sb->s_root = d_make_root(inode);
310 if (!sb->s_root) {
311 err = -ENOMEM;
312 goto out_iput;
313 }
314 d_set_d_op(sb->s_root, &sdcardfs_ci_dops);
Daniel Campello35c9e242015-07-20 16:23:50 -0700315
316 /* link the upper and lower dentries */
317 sb->s_root->d_fsdata = NULL;
318 err = new_dentry_private_data(sb->s_root);
319 if (err)
320 goto out_freeroot;
321
322 /* set the lower dentries for s_root */
323 sdcardfs_set_lower_path(sb->s_root, &lower_path);
324
Daniel Campellod1d080c2015-07-20 16:27:37 -0700325 /*
326 * No need to call interpose because we already have a positive
327 * dentry, which was instantiated by d_make_root. Just need to
328 * d_rehash it.
329 */
330 d_rehash(sb->s_root);
331
332 /* setup permission policy */
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800333 sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
334 mutex_lock(&sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700335 if (sb_info->options.multiuser) {
336 setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
Daniel Rosenberga56a1052017-05-15 14:03:15 -0700337 sb_info->options.fs_user_id, AID_ROOT,
338 false, SDCARDFS_I(d_inode(sb->s_root))->data);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800339 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800340 } else {
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700341 setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
Daniel Rosenberga56a1052017-05-15 14:03:15 -0700342 sb_info->options.fs_user_id, AID_ROOT,
343 false, SDCARDFS_I(d_inode(sb->s_root))->data);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800344 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700345 }
Daniel Rosenberg90219272016-10-26 20:27:20 -0700346 fixup_tmp_permissions(d_inode(sb->s_root));
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800347 sb_info->sb = sb;
348 list_add(&sb_info->list, &sdcardfs_super_list);
349 mutex_unlock(&sdcardfs_super_list_lock);
Daniel Campello35c9e242015-07-20 16:23:50 -0700350
Daniel Campellod1d080c2015-07-20 16:27:37 -0700351 if (!silent)
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700352 pr_info("sdcardfs: mounted on top of %s type %s\n",
Daniel Campellod1d080c2015-07-20 16:27:37 -0700353 dev_name, lower_sb->s_type->name);
354 goto out; /* all is well */
355
356 /* no longer needed: free_dentry_private_data(sb->s_root); */
Daniel Campello35c9e242015-07-20 16:23:50 -0700357out_freeroot:
358 dput(sb->s_root);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700359out_iput:
360 iput(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700361out_sput:
362 /* drop refs we took earlier */
363 atomic_dec(&lower_sb->s_active);
Daniel Campello35c9e242015-07-20 16:23:50 -0700364out_freesbi:
365 kfree(SDCARDFS_SB(sb));
366 sb->s_fs_info = NULL;
367out_free:
368 path_put(&lower_path);
369
370out:
371 return err;
372}
373
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800374struct sdcardfs_mount_private {
375 struct vfsmount *mnt;
376 const char *dev_name;
377 void *raw_data;
378};
Daniel Campello35c9e242015-07-20 16:23:50 -0700379
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800380static int __sdcardfs_fill_super(
381 struct super_block *sb,
382 void *_priv, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700383{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800384 struct sdcardfs_mount_private *priv = _priv;
Daniel Campello35c9e242015-07-20 16:23:50 -0700385
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800386 return sdcardfs_read_super(priv->mnt,
387 sb, priv->dev_name, priv->raw_data, silent);
Daniel Campello35c9e242015-07-20 16:23:50 -0700388}
389
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700390static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
391 struct file_system_type *fs_type, int flags,
Daniel Campello35c9e242015-07-20 16:23:50 -0700392 const char *dev_name, void *raw_data)
393{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800394 struct sdcardfs_mount_private priv = {
395 .mnt = mnt,
396 .dev_name = dev_name,
397 .raw_data = raw_data
398 };
399
400 return mount_nodev(fs_type, flags,
401 &priv, __sdcardfs_fill_super);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700402}
403
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700404static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
405 int flags, const char *dev_name, void *raw_data)
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700406{
407 WARN(1, "sdcardfs does not support mount. Use mount2.\n");
408 return ERR_PTR(-EINVAL);
409}
410
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700411void *sdcardfs_alloc_mnt_data(void)
412{
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700413 return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
Daniel Campello35c9e242015-07-20 16:23:50 -0700414}
415
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700416void sdcardfs_kill_sb(struct super_block *sb)
417{
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800418 struct sdcardfs_sb_info *sbi;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700419
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800420 if (sb->s_magic == SDCARDFS_SUPER_MAGIC) {
421 sbi = SDCARDFS_SB(sb);
422 mutex_lock(&sdcardfs_super_list_lock);
423 list_del(&sbi->list);
424 mutex_unlock(&sdcardfs_super_list_lock);
425 }
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800426 kill_anon_super(sb);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800427}
428
Daniel Campello35c9e242015-07-20 16:23:50 -0700429static struct file_system_type sdcardfs_fs_type = {
430 .owner = THIS_MODULE,
431 .name = SDCARDFS_NAME,
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700432 .mount = sdcardfs_mount_wrn,
433 .mount2 = sdcardfs_mount,
434 .alloc_mnt_data = sdcardfs_alloc_mnt_data,
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800435 .kill_sb = sdcardfs_kill_sb,
Daniel Campellod1d080c2015-07-20 16:27:37 -0700436 .fs_flags = 0,
Daniel Campello35c9e242015-07-20 16:23:50 -0700437};
Daniel Rosenberg35ba5f62017-03-09 20:59:18 -0800438MODULE_ALIAS_FS(SDCARDFS_NAME);
Daniel Campello35c9e242015-07-20 16:23:50 -0700439
440static int __init init_sdcardfs_fs(void)
441{
442 int err;
443
444 pr_info("Registering sdcardfs " SDCARDFS_VERSION "\n");
445
446 err = sdcardfs_init_inode_cache();
447 if (err)
448 goto out;
449 err = sdcardfs_init_dentry_cache();
450 if (err)
451 goto out;
452 err = packagelist_init();
453 if (err)
454 goto out;
455 err = register_filesystem(&sdcardfs_fs_type);
456out:
457 if (err) {
458 sdcardfs_destroy_inode_cache();
459 sdcardfs_destroy_dentry_cache();
460 packagelist_exit();
461 }
462 return err;
463}
464
465static void __exit exit_sdcardfs_fs(void)
466{
467 sdcardfs_destroy_inode_cache();
468 sdcardfs_destroy_dentry_cache();
469 packagelist_exit();
470 unregister_filesystem(&sdcardfs_fs_type);
471 pr_info("Completed sdcardfs module unload\n");
472}
473
Daniel Rosenberg75665df2017-03-09 20:56:05 -0800474/* Original wrapfs authors */
475MODULE_AUTHOR("Erez Zadok, Filesystems and Storage Lab, Stony Brook University (http://www.fsl.cs.sunysb.edu/)");
476
477/* Original sdcardfs authors */
478MODULE_AUTHOR("Woojoong Lee, Daeho Jeong, Kitae Lee, Yeongjin Gil System Memory Lab., Samsung Electronics");
479
480/* Current maintainer */
481MODULE_AUTHOR("Daniel Rosenberg, Google");
482MODULE_DESCRIPTION("Sdcardfs " SDCARDFS_VERSION);
Daniel Campello35c9e242015-07-20 16:23:50 -0700483MODULE_LICENSE("GPL");
484
485module_init(init_sdcardfs_fs);
486module_exit(exit_sdcardfs_fs);