blob: 3d1023a7ff7c2d7bf737bc30c9f0fdea92bc1bd6 [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 Rosenberg173c52e2018-01-02 14:44:49 -080073 vfsopts->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:
129 vfsopts->default_normal = true;
Daniel Campello35c9e242015-07-20 16:23:50 -0700130 /* unknown option */
131 default:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700132 if (!silent)
133 pr_err("Unrecognized mount option \"%s\" or missing value", p);
Daniel Campello35c9e242015-07-20 16:23:50 -0700134 return -EINVAL;
135 }
136 }
137
138 if (*debug) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700139 pr_info("sdcardfs : options - debug:%d\n", *debug);
140 pr_info("sdcardfs : options - uid:%d\n",
Daniel Campello35c9e242015-07-20 16:23:50 -0700141 opts->fs_low_uid);
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700142 pr_info("sdcardfs : options - gid:%d\n",
Daniel Campello35c9e242015-07-20 16:23:50 -0700143 opts->fs_low_gid);
144 }
145
146 return 0;
147}
148
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700149int parse_options_remount(struct super_block *sb, char *options, int silent,
150 struct sdcardfs_vfsmount_options *vfsopts)
151{
152 char *p;
153 substring_t args[MAX_OPT_ARGS];
154 int option;
155 int debug;
156
157 if (!options)
158 return 0;
159
160 while ((p = strsep(&options, ",")) != NULL) {
161 int token;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700162
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700163 if (!*p)
164 continue;
165
166 token = match_token(p, sdcardfs_tokens, args);
167
168 switch (token) {
169 case Opt_debug:
170 debug = 1;
171 break;
172 case Opt_gid:
173 if (match_int(&args[0], &option))
174 return 0;
175 vfsopts->gid = option;
176
177 break;
178 case Opt_mask:
179 if (match_int(&args[0], &option))
180 return 0;
181 vfsopts->mask = option;
182 break;
Daniel Rosenberg173c52e2018-01-02 14:44:49 -0800183 case Opt_default_normal:
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700184 case Opt_multiuser:
185 case Opt_userid:
186 case Opt_fsuid:
187 case Opt_fsgid:
188 case Opt_reserved_mb:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700189 pr_warn("Option \"%s\" can't be changed during remount\n", p);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700190 break;
191 /* unknown option */
192 default:
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700193 if (!silent)
194 pr_err("Unrecognized mount option \"%s\" or missing value", p);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700195 return -EINVAL;
196 }
197 }
198
199 if (debug) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700200 pr_info("sdcardfs : options - debug:%d\n", debug);
201 pr_info("sdcardfs : options - gid:%d\n", vfsopts->gid);
202 pr_info("sdcardfs : options - mask:%d\n", vfsopts->mask);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700203 }
204
205 return 0;
206}
207
Daniel Campellod1d080c2015-07-20 16:27:37 -0700208#if 0
Daniel Campello35c9e242015-07-20 16:23:50 -0700209/*
210 * our custom d_alloc_root work-alike
211 *
212 * we can't use d_alloc_root if we want to use our own interpose function
213 * unchanged, so we simply call our own "fake" d_alloc_root
214 */
215static struct dentry *sdcardfs_d_alloc_root(struct super_block *sb)
216{
217 struct dentry *ret = NULL;
218
219 if (sb) {
220 static const struct qstr name = {
221 .name = "/",
222 .len = 1
223 };
224
225 ret = d_alloc(NULL, &name);
226 if (ret) {
227 d_set_d_op(ret, &sdcardfs_ci_dops);
228 ret->d_sb = sb;
229 ret->d_parent = ret;
230 }
231 }
232 return ret;
233}
Daniel Campellod1d080c2015-07-20 16:27:37 -0700234#endif
Daniel Campello35c9e242015-07-20 16:23:50 -0700235
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800236DEFINE_MUTEX(sdcardfs_super_list_lock);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800237EXPORT_SYMBOL_GPL(sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700238LIST_HEAD(sdcardfs_super_list);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800239EXPORT_SYMBOL_GPL(sdcardfs_super_list);
240
Daniel Campello35c9e242015-07-20 16:23:50 -0700241/*
242 * There is no need to lock the sdcardfs_super_info's rwsem as there is no
243 * way anyone can have a reference to the superblock at this point in time.
244 */
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700245static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
246 const char *dev_name, void *raw_data, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700247{
248 int err = 0;
249 int debug;
250 struct super_block *lower_sb;
251 struct path lower_path;
252 struct sdcardfs_sb_info *sb_info;
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700253 struct sdcardfs_vfsmount_options *mnt_opt = mnt->data;
Daniel Campellod1d080c2015-07-20 16:27:37 -0700254 struct inode *inode;
Daniel Campello35c9e242015-07-20 16:23:50 -0700255
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700256 pr_info("sdcardfs version 2.0\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700257
258 if (!dev_name) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700259 pr_err("sdcardfs: read_super: missing dev_name argument\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700260 err = -EINVAL;
261 goto out;
262 }
263
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700264 pr_info("sdcardfs: dev_name -> %s\n", dev_name);
265 pr_info("sdcardfs: options -> %s\n", (char *)raw_data);
266 pr_info("sdcardfs: mnt -> %p\n", mnt);
Daniel Campello35c9e242015-07-20 16:23:50 -0700267
268 /* parse lower path */
269 err = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
270 &lower_path);
271 if (err) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700272 pr_err("sdcardfs: error accessing lower directory '%s'\n", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700273 goto out;
274 }
275
276 /* allocate superblock private data */
277 sb->s_fs_info = kzalloc(sizeof(struct sdcardfs_sb_info), GFP_KERNEL);
278 if (!SDCARDFS_SB(sb)) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700279 pr_crit("sdcardfs: read_super: out of memory\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700280 err = -ENOMEM;
281 goto out_free;
282 }
283
284 sb_info = sb->s_fs_info;
Daniel Campello35c9e242015-07-20 16:23:50 -0700285 /* parse options */
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700286 err = parse_options(sb, raw_data, silent, &debug, mnt_opt, &sb_info->options);
Daniel Campello35c9e242015-07-20 16:23:50 -0700287 if (err) {
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700288 pr_err("sdcardfs: invalid options\n");
Daniel Campello35c9e242015-07-20 16:23:50 -0700289 goto out_freesbi;
290 }
291
Daniel Campello35c9e242015-07-20 16:23:50 -0700292 /* set the lower superblock field of upper superblock */
293 lower_sb = lower_path.dentry->d_sb;
294 atomic_inc(&lower_sb->s_active);
295 sdcardfs_set_lower_super(sb, lower_sb);
296
297 /* inherit maxbytes from lower file system */
298 sb->s_maxbytes = lower_sb->s_maxbytes;
299
300 /*
301 * Our c/m/atime granularity is 1 ns because we may stack on file
302 * systems whose granularity is as good.
303 */
304 sb->s_time_gran = 1;
305
306 sb->s_magic = SDCARDFS_SUPER_MAGIC;
307 sb->s_op = &sdcardfs_sops;
308
Daniel Campellod1d080c2015-07-20 16:27:37 -0700309 /* get a new inode and allocate our root dentry */
Daniel Rosenberg63d20762016-12-01 14:36:29 -0800310 inode = sdcardfs_iget(sb, d_inode(lower_path.dentry), 0);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700311 if (IS_ERR(inode)) {
312 err = PTR_ERR(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700313 goto out_sput;
314 }
Daniel Campellod1d080c2015-07-20 16:27:37 -0700315 sb->s_root = d_make_root(inode);
316 if (!sb->s_root) {
317 err = -ENOMEM;
318 goto out_iput;
319 }
320 d_set_d_op(sb->s_root, &sdcardfs_ci_dops);
Daniel Campello35c9e242015-07-20 16:23:50 -0700321
322 /* link the upper and lower dentries */
323 sb->s_root->d_fsdata = NULL;
324 err = new_dentry_private_data(sb->s_root);
325 if (err)
326 goto out_freeroot;
327
328 /* set the lower dentries for s_root */
329 sdcardfs_set_lower_path(sb->s_root, &lower_path);
330
Daniel Campellod1d080c2015-07-20 16:27:37 -0700331 /*
332 * No need to call interpose because we already have a positive
333 * dentry, which was instantiated by d_make_root. Just need to
334 * d_rehash it.
335 */
336 d_rehash(sb->s_root);
337
338 /* setup permission policy */
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800339 sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
340 mutex_lock(&sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700341 if (sb_info->options.multiuser) {
342 setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
Daniel Rosenberga56a1052017-05-15 14:03:15 -0700343 sb_info->options.fs_user_id, AID_ROOT,
344 false, SDCARDFS_I(d_inode(sb->s_root))->data);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800345 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800346 } else {
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700347 setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
Daniel Rosenberga56a1052017-05-15 14:03:15 -0700348 sb_info->options.fs_user_id, AID_ROOT,
349 false, SDCARDFS_I(d_inode(sb->s_root))->data);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800350 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700351 }
Daniel Rosenberg90219272016-10-26 20:27:20 -0700352 fixup_tmp_permissions(d_inode(sb->s_root));
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800353 sb_info->sb = sb;
354 list_add(&sb_info->list, &sdcardfs_super_list);
355 mutex_unlock(&sdcardfs_super_list_lock);
Daniel Campello35c9e242015-07-20 16:23:50 -0700356
Daniel Campellod1d080c2015-07-20 16:27:37 -0700357 if (!silent)
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700358 pr_info("sdcardfs: mounted on top of %s type %s\n",
Daniel Campellod1d080c2015-07-20 16:27:37 -0700359 dev_name, lower_sb->s_type->name);
360 goto out; /* all is well */
361
362 /* no longer needed: free_dentry_private_data(sb->s_root); */
Daniel Campello35c9e242015-07-20 16:23:50 -0700363out_freeroot:
364 dput(sb->s_root);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700365out_iput:
366 iput(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700367out_sput:
368 /* drop refs we took earlier */
369 atomic_dec(&lower_sb->s_active);
Daniel Campello35c9e242015-07-20 16:23:50 -0700370out_freesbi:
371 kfree(SDCARDFS_SB(sb));
372 sb->s_fs_info = NULL;
373out_free:
374 path_put(&lower_path);
375
376out:
377 return err;
378}
379
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800380struct sdcardfs_mount_private {
381 struct vfsmount *mnt;
382 const char *dev_name;
383 void *raw_data;
384};
Daniel Campello35c9e242015-07-20 16:23:50 -0700385
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800386static int __sdcardfs_fill_super(
387 struct super_block *sb,
388 void *_priv, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700389{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800390 struct sdcardfs_mount_private *priv = _priv;
Daniel Campello35c9e242015-07-20 16:23:50 -0700391
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800392 return sdcardfs_read_super(priv->mnt,
393 sb, priv->dev_name, priv->raw_data, silent);
Daniel Campello35c9e242015-07-20 16:23:50 -0700394}
395
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700396static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
397 struct file_system_type *fs_type, int flags,
Daniel Campello35c9e242015-07-20 16:23:50 -0700398 const char *dev_name, void *raw_data)
399{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800400 struct sdcardfs_mount_private priv = {
401 .mnt = mnt,
402 .dev_name = dev_name,
403 .raw_data = raw_data
404 };
405
406 return mount_nodev(fs_type, flags,
407 &priv, __sdcardfs_fill_super);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700408}
409
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700410static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
411 int flags, const char *dev_name, void *raw_data)
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700412{
413 WARN(1, "sdcardfs does not support mount. Use mount2.\n");
414 return ERR_PTR(-EINVAL);
415}
416
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700417void *sdcardfs_alloc_mnt_data(void)
418{
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700419 return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
Daniel Campello35c9e242015-07-20 16:23:50 -0700420}
421
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700422void sdcardfs_kill_sb(struct super_block *sb)
423{
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800424 struct sdcardfs_sb_info *sbi;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700425
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800426 if (sb->s_magic == SDCARDFS_SUPER_MAGIC) {
427 sbi = SDCARDFS_SB(sb);
428 mutex_lock(&sdcardfs_super_list_lock);
429 list_del(&sbi->list);
430 mutex_unlock(&sdcardfs_super_list_lock);
431 }
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800432 kill_anon_super(sb);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800433}
434
Daniel Campello35c9e242015-07-20 16:23:50 -0700435static struct file_system_type sdcardfs_fs_type = {
436 .owner = THIS_MODULE,
437 .name = SDCARDFS_NAME,
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700438 .mount = sdcardfs_mount_wrn,
439 .mount2 = sdcardfs_mount,
440 .alloc_mnt_data = sdcardfs_alloc_mnt_data,
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800441 .kill_sb = sdcardfs_kill_sb,
Daniel Campellod1d080c2015-07-20 16:27:37 -0700442 .fs_flags = 0,
Daniel Campello35c9e242015-07-20 16:23:50 -0700443};
Daniel Rosenberg35ba5f62017-03-09 20:59:18 -0800444MODULE_ALIAS_FS(SDCARDFS_NAME);
Daniel Campello35c9e242015-07-20 16:23:50 -0700445
446static int __init init_sdcardfs_fs(void)
447{
448 int err;
449
450 pr_info("Registering sdcardfs " SDCARDFS_VERSION "\n");
451
452 err = sdcardfs_init_inode_cache();
453 if (err)
454 goto out;
455 err = sdcardfs_init_dentry_cache();
456 if (err)
457 goto out;
458 err = packagelist_init();
459 if (err)
460 goto out;
461 err = register_filesystem(&sdcardfs_fs_type);
462out:
463 if (err) {
464 sdcardfs_destroy_inode_cache();
465 sdcardfs_destroy_dentry_cache();
466 packagelist_exit();
467 }
468 return err;
469}
470
471static void __exit exit_sdcardfs_fs(void)
472{
473 sdcardfs_destroy_inode_cache();
474 sdcardfs_destroy_dentry_cache();
475 packagelist_exit();
476 unregister_filesystem(&sdcardfs_fs_type);
477 pr_info("Completed sdcardfs module unload\n");
478}
479
Daniel Rosenberg75665df2017-03-09 20:56:05 -0800480/* Original wrapfs authors */
481MODULE_AUTHOR("Erez Zadok, Filesystems and Storage Lab, Stony Brook University (http://www.fsl.cs.sunysb.edu/)");
482
483/* Original sdcardfs authors */
484MODULE_AUTHOR("Woojoong Lee, Daeho Jeong, Kitae Lee, Yeongjin Gil System Memory Lab., Samsung Electronics");
485
486/* Current maintainer */
487MODULE_AUTHOR("Daniel Rosenberg, Google");
488MODULE_DESCRIPTION("Sdcardfs " SDCARDFS_VERSION);
Daniel Campello35c9e242015-07-20 16:23:50 -0700489MODULE_LICENSE("GPL");
490
491module_init(init_sdcardfs_fs);
492module_exit(exit_sdcardfs_fs);