blob: ac27bb301c5e8219c62c9d0005753c4b98a44516 [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
298 /* inherit maxbytes from lower file system */
299 sb->s_maxbytes = lower_sb->s_maxbytes;
300
301 /*
302 * Our c/m/atime granularity is 1 ns because we may stack on file
303 * systems whose granularity is as good.
304 */
305 sb->s_time_gran = 1;
306
307 sb->s_magic = SDCARDFS_SUPER_MAGIC;
308 sb->s_op = &sdcardfs_sops;
309
Daniel Campellod1d080c2015-07-20 16:27:37 -0700310 /* get a new inode and allocate our root dentry */
Daniel Rosenberg63d20762016-12-01 14:36:29 -0800311 inode = sdcardfs_iget(sb, d_inode(lower_path.dentry), 0);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700312 if (IS_ERR(inode)) {
313 err = PTR_ERR(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700314 goto out_sput;
315 }
Daniel Campellod1d080c2015-07-20 16:27:37 -0700316 sb->s_root = d_make_root(inode);
317 if (!sb->s_root) {
318 err = -ENOMEM;
319 goto out_iput;
320 }
321 d_set_d_op(sb->s_root, &sdcardfs_ci_dops);
Daniel Campello35c9e242015-07-20 16:23:50 -0700322
323 /* link the upper and lower dentries */
324 sb->s_root->d_fsdata = NULL;
325 err = new_dentry_private_data(sb->s_root);
326 if (err)
327 goto out_freeroot;
328
329 /* set the lower dentries for s_root */
330 sdcardfs_set_lower_path(sb->s_root, &lower_path);
331
Daniel Campellod1d080c2015-07-20 16:27:37 -0700332 /*
333 * No need to call interpose because we already have a positive
334 * dentry, which was instantiated by d_make_root. Just need to
335 * d_rehash it.
336 */
337 d_rehash(sb->s_root);
338
339 /* setup permission policy */
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800340 sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
341 mutex_lock(&sdcardfs_super_list_lock);
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700342 if (sb_info->options.multiuser) {
343 setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
Daniel Rosenberga56a1052017-05-15 14:03:15 -0700344 sb_info->options.fs_user_id, AID_ROOT,
345 false, SDCARDFS_I(d_inode(sb->s_root))->data);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800346 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800347 } else {
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700348 setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
Daniel Rosenberga56a1052017-05-15 14:03:15 -0700349 sb_info->options.fs_user_id, AID_ROOT,
350 false, SDCARDFS_I(d_inode(sb->s_root))->data);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800351 snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
Daniel Campello35c9e242015-07-20 16:23:50 -0700352 }
Daniel Rosenberg90219272016-10-26 20:27:20 -0700353 fixup_tmp_permissions(d_inode(sb->s_root));
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800354 sb_info->sb = sb;
355 list_add(&sb_info->list, &sdcardfs_super_list);
356 mutex_unlock(&sdcardfs_super_list_lock);
Daniel Campello35c9e242015-07-20 16:23:50 -0700357
Daniel Campellod1d080c2015-07-20 16:27:37 -0700358 if (!silent)
Daniel Rosenberg77ecf212017-03-16 17:46:13 -0700359 pr_info("sdcardfs: mounted on top of %s type %s\n",
Daniel Campellod1d080c2015-07-20 16:27:37 -0700360 dev_name, lower_sb->s_type->name);
361 goto out; /* all is well */
362
363 /* no longer needed: free_dentry_private_data(sb->s_root); */
Daniel Campello35c9e242015-07-20 16:23:50 -0700364out_freeroot:
365 dput(sb->s_root);
Daniel Campellod1d080c2015-07-20 16:27:37 -0700366out_iput:
367 iput(inode);
Daniel Campello35c9e242015-07-20 16:23:50 -0700368out_sput:
369 /* drop refs we took earlier */
370 atomic_dec(&lower_sb->s_active);
Daniel Campello35c9e242015-07-20 16:23:50 -0700371out_freesbi:
372 kfree(SDCARDFS_SB(sb));
373 sb->s_fs_info = NULL;
374out_free:
375 path_put(&lower_path);
376
377out:
378 return err;
379}
380
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800381struct sdcardfs_mount_private {
382 struct vfsmount *mnt;
383 const char *dev_name;
384 void *raw_data;
385};
Daniel Campello35c9e242015-07-20 16:23:50 -0700386
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800387static int __sdcardfs_fill_super(
388 struct super_block *sb,
389 void *_priv, int silent)
Daniel Campello35c9e242015-07-20 16:23:50 -0700390{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800391 struct sdcardfs_mount_private *priv = _priv;
Daniel Campello35c9e242015-07-20 16:23:50 -0700392
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800393 return sdcardfs_read_super(priv->mnt,
394 sb, priv->dev_name, priv->raw_data, silent);
Daniel Campello35c9e242015-07-20 16:23:50 -0700395}
396
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700397static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
398 struct file_system_type *fs_type, int flags,
Daniel Campello35c9e242015-07-20 16:23:50 -0700399 const char *dev_name, void *raw_data)
400{
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800401 struct sdcardfs_mount_private priv = {
402 .mnt = mnt,
403 .dev_name = dev_name,
404 .raw_data = raw_data
405 };
406
407 return mount_nodev(fs_type, flags,
408 &priv, __sdcardfs_fill_super);
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700409}
410
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700411static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
412 int flags, const char *dev_name, void *raw_data)
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700413{
414 WARN(1, "sdcardfs does not support mount. Use mount2.\n");
415 return ERR_PTR(-EINVAL);
416}
417
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700418void *sdcardfs_alloc_mnt_data(void)
419{
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700420 return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
Daniel Campello35c9e242015-07-20 16:23:50 -0700421}
422
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700423void sdcardfs_kill_sb(struct super_block *sb)
424{
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800425 struct sdcardfs_sb_info *sbi;
Daniel Rosenberg5e024f62017-03-16 17:42:58 -0700426
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800427 if (sb->s_magic == SDCARDFS_SUPER_MAGIC) {
428 sbi = SDCARDFS_SB(sb);
429 mutex_lock(&sdcardfs_super_list_lock);
430 list_del(&sbi->list);
431 mutex_unlock(&sdcardfs_super_list_lock);
432 }
Gao Xiangb2ac1fd2017-05-09 12:30:56 +0800433 kill_anon_super(sb);
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800434}
435
Daniel Campello35c9e242015-07-20 16:23:50 -0700436static struct file_system_type sdcardfs_fs_type = {
437 .owner = THIS_MODULE,
438 .name = SDCARDFS_NAME,
Daniel Rosenberg317e7702016-10-26 17:36:05 -0700439 .mount = sdcardfs_mount_wrn,
440 .mount2 = sdcardfs_mount,
441 .alloc_mnt_data = sdcardfs_alloc_mnt_data,
Daniel Rosenberg497ac902016-02-03 21:08:21 -0800442 .kill_sb = sdcardfs_kill_sb,
Daniel Campellod1d080c2015-07-20 16:27:37 -0700443 .fs_flags = 0,
Daniel Campello35c9e242015-07-20 16:23:50 -0700444};
Daniel Rosenberg35ba5f62017-03-09 20:59:18 -0800445MODULE_ALIAS_FS(SDCARDFS_NAME);
Daniel Campello35c9e242015-07-20 16:23:50 -0700446
447static int __init init_sdcardfs_fs(void)
448{
449 int err;
450
451 pr_info("Registering sdcardfs " SDCARDFS_VERSION "\n");
452
453 err = sdcardfs_init_inode_cache();
454 if (err)
455 goto out;
456 err = sdcardfs_init_dentry_cache();
457 if (err)
458 goto out;
459 err = packagelist_init();
460 if (err)
461 goto out;
462 err = register_filesystem(&sdcardfs_fs_type);
463out:
464 if (err) {
465 sdcardfs_destroy_inode_cache();
466 sdcardfs_destroy_dentry_cache();
467 packagelist_exit();
468 }
469 return err;
470}
471
472static void __exit exit_sdcardfs_fs(void)
473{
474 sdcardfs_destroy_inode_cache();
475 sdcardfs_destroy_dentry_cache();
476 packagelist_exit();
477 unregister_filesystem(&sdcardfs_fs_type);
478 pr_info("Completed sdcardfs module unload\n");
479}
480
Daniel Rosenberg75665df2017-03-09 20:56:05 -0800481/* Original wrapfs authors */
482MODULE_AUTHOR("Erez Zadok, Filesystems and Storage Lab, Stony Brook University (http://www.fsl.cs.sunysb.edu/)");
483
484/* Original sdcardfs authors */
485MODULE_AUTHOR("Woojoong Lee, Daeho Jeong, Kitae Lee, Yeongjin Gil System Memory Lab., Samsung Electronics");
486
487/* Current maintainer */
488MODULE_AUTHOR("Daniel Rosenberg, Google");
489MODULE_DESCRIPTION("Sdcardfs " SDCARDFS_VERSION);
Daniel Campello35c9e242015-07-20 16:23:50 -0700490MODULE_LICENSE("GPL");
491
492module_init(init_sdcardfs_fs);
493module_exit(exit_sdcardfs_fs);