^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * fs/sdcardfs/main.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2013 Samsung Electronics Co. Ltd
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Authors: Daeho Jeong, Woojoong Lee, Seunghwan Hyun,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Sunghwan Yun, Sungjong Seo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This program has been developed as a stackable file system based on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * the WrapFS which written by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * Copyright (c) 1998-2011 Erez Zadok
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * Copyright (c) 2009 Shrikar Archak
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * Copyright (c) 2003-2011 Stony Brook University
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * Copyright (c) 2003-2011 The Research Foundation of SUNY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * This file is dual licensed. It may be redistributed and/or modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * under the terms of the Apache 2.0 License OR version 2 of the GNU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * General Public License.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "sdcardfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/fscrypt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <linux/parser.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) Opt_fsuid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) Opt_fsgid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) Opt_gid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) Opt_debug,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) Opt_mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) Opt_multiuser,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) Opt_userid,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) Opt_reserved_mb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Opt_gid_derivation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) Opt_default_normal,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) Opt_nocache,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) Opt_unshared_obb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) Opt_err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) static const match_table_t sdcardfs_tokens = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) {Opt_fsuid, "fsuid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {Opt_fsgid, "fsgid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {Opt_gid, "gid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) {Opt_debug, "debug"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) {Opt_mask, "mask=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) {Opt_userid, "userid=%d"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {Opt_multiuser, "multiuser"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {Opt_gid_derivation, "derive_gid"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) {Opt_default_normal, "default_normal"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {Opt_unshared_obb, "unshared_obb"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {Opt_reserved_mb, "reserved_mb=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {Opt_nocache, "nocache"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) {Opt_err, NULL}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static int parse_options(struct super_block *sb, char *options, int silent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) int *debug, struct sdcardfs_vfsmount_options *vfsopts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) struct sdcardfs_mount_options *opts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) substring_t args[MAX_OPT_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) int option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /* by default, we use AID_MEDIA_RW as uid, gid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) opts->fs_low_uid = AID_MEDIA_RW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) opts->fs_low_gid = AID_MEDIA_RW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) vfsopts->mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) opts->multiuser = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) opts->fs_user_id = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) vfsopts->gid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) /* by default, 0MB is reserved */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) opts->reserved_mb = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /* by default, gid derivation is off */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) opts->gid_derivation = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) opts->default_normal = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) opts->nocache = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) *debug = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (!options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) while ((p = strsep(&options, ",")) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) int token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (!*p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) token = match_token(p, sdcardfs_tokens, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) switch (token) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) case Opt_debug:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) *debug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) case Opt_fsuid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) opts->fs_low_uid = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) case Opt_fsgid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) opts->fs_low_gid = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) case Opt_gid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) vfsopts->gid = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) case Opt_userid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) opts->fs_user_id = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) case Opt_mask:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) vfsopts->mask = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) case Opt_multiuser:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) opts->multiuser = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) case Opt_reserved_mb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) opts->reserved_mb = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) case Opt_gid_derivation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) opts->gid_derivation = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) case Opt_default_normal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) opts->default_normal = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) case Opt_nocache:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) opts->nocache = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) case Opt_unshared_obb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) opts->unshared_obb = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /* unknown option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) pr_err("Unrecognized mount option \"%s\" or missing value", p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) if (*debug) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) pr_info("sdcardfs : options - debug:%d\n", *debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) pr_info("sdcardfs : options - uid:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) opts->fs_low_uid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) pr_info("sdcardfs : options - gid:%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) opts->fs_low_gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) int parse_options_remount(struct super_block *sb, char *options, int silent,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) struct sdcardfs_vfsmount_options *vfsopts)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) substring_t args[MAX_OPT_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) int option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) int debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (!options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) while ((p = strsep(&options, ",")) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) int token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (!*p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) token = match_token(p, sdcardfs_tokens, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) switch (token) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) case Opt_debug:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) debug = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) case Opt_gid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) vfsopts->gid = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) case Opt_mask:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) vfsopts->mask = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) case Opt_unshared_obb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) case Opt_default_normal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) case Opt_multiuser:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) case Opt_userid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) case Opt_fsuid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) case Opt_fsgid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) case Opt_reserved_mb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) case Opt_gid_derivation:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) pr_warn("Option \"%s\" can't be changed during remount\n", p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) /* unknown option */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) pr_err("Unrecognized mount option \"%s\" or missing value", p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (debug) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) pr_info("sdcardfs : options - debug:%d\n", debug);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) pr_info("sdcardfs : options - gid:%d\n", vfsopts->gid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) pr_info("sdcardfs : options - mask:%d\n", vfsopts->mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) #if 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) * our custom d_alloc_root work-alike
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) * we can't use d_alloc_root if we want to use our own interpose function
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) * unchanged, so we simply call our own "fake" d_alloc_root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) static struct dentry *sdcardfs_d_alloc_root(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) struct dentry *ret = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) if (sb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) static const struct qstr name = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) .name = "/",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) .len = 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) ret = d_alloc(NULL, &name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) if (ret) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) d_set_d_op(ret, &sdcardfs_ci_dops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) ret->d_sb = sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ret->d_parent = ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) DEFINE_MUTEX(sdcardfs_super_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) EXPORT_SYMBOL_GPL(sdcardfs_super_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) LIST_HEAD(sdcardfs_super_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) EXPORT_SYMBOL_GPL(sdcardfs_super_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) * There is no need to lock the sdcardfs_super_info's rwsem as there is no
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) * way anyone can have a reference to the superblock at this point in time.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) static int sdcardfs_read_super(struct vfsmount *mnt, struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) const char *dev_name, void *raw_data, int silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) int err = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) int debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) struct super_block *lower_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) struct path lower_path;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) struct sdcardfs_sb_info *sb_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) struct sdcardfs_vfsmount_options *mnt_opt = mnt->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) pr_info("sdcardfs version 2.0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) if (!dev_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) pr_err("sdcardfs: read_super: missing dev_name argument\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) pr_info("sdcardfs: dev_name -> %s\n", dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) pr_info("sdcardfs: options -> %s\n", (char *)raw_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) pr_info("sdcardfs: mnt -> %p\n", mnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) /* parse lower path */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) err = kern_path(dev_name, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) &lower_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) pr_err("sdcardfs: error accessing lower directory '%s'\n", dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) /* allocate superblock private data */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) sb->s_fs_info = kzalloc(sizeof(struct sdcardfs_sb_info), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (!SDCARDFS_SB(sb)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) pr_crit("sdcardfs: read_super: out of memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) goto out_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) sb_info = sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) /* parse options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) err = parse_options(sb, raw_data, silent, &debug, mnt_opt, &sb_info->options);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) pr_err("sdcardfs: invalid options\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) goto out_freesbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) /* set the lower superblock field of upper superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) lower_sb = lower_path.dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) atomic_inc(&lower_sb->s_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) sdcardfs_set_lower_super(sb, lower_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) sb->s_stack_depth = lower_sb->s_stack_depth + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) if (sb->s_stack_depth > FILESYSTEM_MAX_STACK_DEPTH) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) pr_err("sdcardfs: maximum fs stacking depth exceeded\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) err = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) goto out_sput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) /* inherit maxbytes from lower file system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) sb->s_maxbytes = lower_sb->s_maxbytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * Our c/m/atime granularity is 1 ns because we may stack on file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) * systems whose granularity is as good.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) sb->s_time_gran = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) sb->s_magic = SDCARDFS_SUPER_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) sb->s_op = &sdcardfs_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) /* get a new inode and allocate our root dentry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) inode = sdcardfs_iget(sb, d_inode(lower_path.dentry), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) if (IS_ERR(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) err = PTR_ERR(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) goto out_sput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) sb->s_root = d_make_root(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) if (!sb->s_root) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) err = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) goto out_sput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) d_set_d_op(sb->s_root, &sdcardfs_ci_dops);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) /* link the upper and lower dentries */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) sb->s_root->d_fsdata = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) err = new_dentry_private_data(sb->s_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) goto out_freeroot;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) /* set the lower dentries for s_root */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) sdcardfs_set_lower_path(sb->s_root, &lower_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * No need to call interpose because we already have a positive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * dentry, which was instantiated by d_make_root. Just need to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) * d_rehash it.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) d_rehash(sb->s_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) /* setup permission policy */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) sb_info->obbpath_s = kzalloc(PATH_MAX, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) mutex_lock(&sdcardfs_super_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (sb_info->options.multiuser) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) setup_derived_state(d_inode(sb->s_root), PERM_PRE_ROOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) sb_info->options.fs_user_id, AID_ROOT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) snprintf(sb_info->obbpath_s, PATH_MAX, "%s/obb", dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) setup_derived_state(d_inode(sb->s_root), PERM_ROOT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) sb_info->options.fs_user_id, AID_ROOT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) snprintf(sb_info->obbpath_s, PATH_MAX, "%s/Android/obb", dev_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) fixup_tmp_permissions(d_inode(sb->s_root));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) sb_info->sb = sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) list_add(&sb_info->list, &sdcardfs_super_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) mutex_unlock(&sdcardfs_super_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) sb_info->fscrypt_nb.notifier_call = sdcardfs_on_fscrypt_key_removed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) fscrypt_register_key_removal_notifier(&sb_info->fscrypt_nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) pr_info("sdcardfs: mounted on top of %s type %s\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) dev_name, lower_sb->s_type->name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) goto out; /* all is well */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) /* no longer needed: free_dentry_private_data(sb->s_root); */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) out_freeroot:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) dput(sb->s_root);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) sb->s_root = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) out_sput:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) /* drop refs we took earlier */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) atomic_dec(&lower_sb->s_active);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) out_freesbi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) kfree(SDCARDFS_SB(sb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) sb->s_fs_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) out_free:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) path_put(&lower_path);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) struct sdcardfs_mount_private {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) struct vfsmount *mnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) const char *dev_name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) void *raw_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) static int __sdcardfs_fill_super(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) void *_priv, int silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) struct sdcardfs_mount_private *priv = _priv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) return sdcardfs_read_super(priv->mnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) sb, priv->dev_name, priv->raw_data, silent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) static struct dentry *sdcardfs_mount(struct vfsmount *mnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) struct file_system_type *fs_type, int flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) const char *dev_name, void *raw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) struct sdcardfs_mount_private priv = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) .mnt = mnt,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) .dev_name = dev_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) .raw_data = raw_data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) return mount_nodev(fs_type, flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) &priv, __sdcardfs_fill_super);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static struct dentry *sdcardfs_mount_wrn(struct file_system_type *fs_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) int flags, const char *dev_name, void *raw_data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) WARN(1, "sdcardfs does not support mount. Use mount2.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) void *sdcardfs_alloc_mnt_data(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) return kmalloc(sizeof(struct sdcardfs_vfsmount_options), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) void sdcardfs_kill_sb(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) struct sdcardfs_sb_info *sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) if (sb->s_magic == SDCARDFS_SUPER_MAGIC && sb->s_fs_info) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) sbi = SDCARDFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) fscrypt_unregister_key_removal_notifier(&sbi->fscrypt_nb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) mutex_lock(&sdcardfs_super_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) list_del(&sbi->list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) mutex_unlock(&sdcardfs_super_list_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) kill_anon_super(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) static struct file_system_type sdcardfs_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) .owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) .name = SDCARDFS_NAME,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) .mount = sdcardfs_mount_wrn,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) .mount2 = sdcardfs_mount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) .alloc_mnt_data = sdcardfs_alloc_mnt_data,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) .kill_sb = sdcardfs_kill_sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) .fs_flags = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) MODULE_ALIAS_FS(SDCARDFS_NAME);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) static int __init init_sdcardfs_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) pr_info("Registering sdcardfs " SDCARDFS_VERSION "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) err = sdcardfs_init_inode_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) err = sdcardfs_init_dentry_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) err = packagelist_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) err = register_filesystem(&sdcardfs_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) if (err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) sdcardfs_destroy_inode_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) sdcardfs_destroy_dentry_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) packagelist_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) static void __exit exit_sdcardfs_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) sdcardfs_destroy_inode_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) sdcardfs_destroy_dentry_cache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) packagelist_exit();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) unregister_filesystem(&sdcardfs_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) pr_info("Completed sdcardfs module unload\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) /* Original wrapfs authors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) MODULE_AUTHOR("Erez Zadok, Filesystems and Storage Lab, Stony Brook University (http://www.fsl.cs.sunysb.edu/)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) /* Original sdcardfs authors */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) MODULE_AUTHOR("Woojoong Lee, Daeho Jeong, Kitae Lee, Yeongjin Gil System Memory Lab., Samsung Electronics");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) /* Current maintainer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) MODULE_AUTHOR("Daniel Rosenberg, Google");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) MODULE_DESCRIPTION("Sdcardfs " SDCARDFS_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) module_init(init_sdcardfs_fs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) module_exit(exit_sdcardfs_fs);