system/core
リビジョン | fb595ea798d0db035e851b8ae389dd774623d926 (tree) |
---|---|
日時 | 2019-07-03 12:58:30 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
コミッター | Chih-Wei Huang |
Revert "Add support for esdfs mounting"
This reverts commit c336f86284ee817a2e846452ad80e5d014d11414.
@@ -43,44 +43,6 @@ | ||
43 | 43 | |
44 | 44 | #include <private/android_filesystem_config.h> |
45 | 45 | |
46 | -#define PROP_SDCARDFS_DEVICE "ro.sys.sdcardfs" | |
47 | -#define PROP_SDCARDFS_USER "persist.sys.sdcardfs" | |
48 | - | |
49 | -static bool supports_esdfs(void) { | |
50 | - std::string filesystems; | |
51 | - if (!android::base::ReadFileToString("/proc/filesystems", &filesystems)) { | |
52 | - PLOG(ERROR) << "Could not read /proc/filesystems"; | |
53 | - return false; | |
54 | - } | |
55 | - for (const auto& fs : android::base::Split(filesystems, "\n")) { | |
56 | - if (fs.find("esdfs") != std::string::npos) return true; | |
57 | - } | |
58 | - return false; | |
59 | -} | |
60 | - | |
61 | -static bool should_use_sdcardfs(void) { | |
62 | - char property[PROPERTY_VALUE_MAX]; | |
63 | - | |
64 | - // Allow user to have a strong opinion about state | |
65 | - property_get(PROP_SDCARDFS_USER, property, ""); | |
66 | - if (!strcmp(property, "force_on")) { | |
67 | - LOG(WARNING) << "User explicitly enabled sdcardfs"; | |
68 | - return true; | |
69 | - } else if (!strcmp(property, "force_off")) { | |
70 | - LOG(WARNING) << "User explicitly disabled sdcardfs"; | |
71 | - return !supports_esdfs(); | |
72 | - } | |
73 | - | |
74 | - // Fall back to device opinion about state | |
75 | - if (property_get_bool(PROP_SDCARDFS_DEVICE, true)) { | |
76 | - LOG(WARNING) << "Device explicitly enabled sdcardfs"; | |
77 | - return true; | |
78 | - } else { | |
79 | - LOG(WARNING) << "Device explicitly disabled sdcardfs"; | |
80 | - return !supports_esdfs(); | |
81 | - } | |
82 | -} | |
83 | - | |
84 | 46 | // NOTE: This is a vestigial program that simply exists to mount the in-kernel |
85 | 47 | // sdcardfs filesystem. The older FUSE-based design that used to live here has |
86 | 48 | // been completely removed to avoid confusion. |
@@ -99,7 +61,7 @@ static void drop_privs(uid_t uid, gid_t gid) { | ||
99 | 61 | |
100 | 62 | static bool sdcardfs_setup(const std::string& source_path, const std::string& dest_path, |
101 | 63 | uid_t fsuid, gid_t fsgid, bool multi_user, userid_t userid, gid_t gid, |
102 | - mode_t mask, bool derive_gid, bool default_normal, bool use_esdfs) { | |
64 | + mode_t mask, bool derive_gid, bool default_normal) { | |
103 | 65 | // Try several attempts, each time with one less option, to gracefully |
104 | 66 | // handle older kernels that aren't updated yet. |
105 | 67 | for (int i = 0; i < 4; i++) { |
@@ -110,7 +72,7 @@ static bool sdcardfs_setup(const std::string& source_path, const std::string& de | ||
110 | 72 | |
111 | 73 | auto opts = android::base::StringPrintf("fsuid=%d,fsgid=%d,%smask=%d,userid=%d,gid=%d", |
112 | 74 | fsuid, fsgid, new_opts.c_str(), mask, userid, gid); |
113 | - if (mount(source_path.c_str(), dest_path.c_str(), use_esdfs ? "esdfs" : "sdcardfs", | |
75 | + if (mount(source_path.c_str(), dest_path.c_str(), "sdcardfs", | |
114 | 76 | MS_NOSUID | MS_NODEV | MS_NOEXEC | MS_NOATIME, opts.c_str()) == -1) { |
115 | 77 | PLOG(WARNING) << "Failed to mount sdcardfs with options " << opts; |
116 | 78 | } else { |
@@ -142,21 +104,9 @@ static bool sdcardfs_setup_bind_remount(const std::string& source_path, const st | ||
142 | 104 | return true; |
143 | 105 | } |
144 | 106 | |
145 | -static bool sdcardfs_setup_secondary(const std::string& default_path, const std::string& source_path, | |
146 | - const std::string& dest_path, uid_t fsuid, gid_t fsgid, | |
147 | - bool multi_user, userid_t userid, gid_t gid, mode_t mask, | |
148 | - bool derive_gid, bool default_normal, bool use_esdfs) { | |
149 | - if (use_esdfs) { | |
150 | - return sdcardfs_setup(source_path, dest_path, fsuid, fsgid, multi_user, userid, gid, mask, | |
151 | - derive_gid, default_normal, use_esdfs); | |
152 | - } else { | |
153 | - return sdcardfs_setup_bind_remount(default_path, dest_path, gid, mask); | |
154 | - } | |
155 | -} | |
156 | - | |
157 | 107 | static void run_sdcardfs(const std::string& source_path, const std::string& label, uid_t uid, |
158 | 108 | gid_t gid, userid_t userid, bool multi_user, bool full_write, |
159 | - bool derive_gid, bool default_normal, bool use_esdfs) { | |
109 | + bool derive_gid, bool default_normal) { | |
160 | 110 | std::string dest_path_default = "/mnt/runtime/default/" + label; |
161 | 111 | std::string dest_path_read = "/mnt/runtime/read/" + label; |
162 | 112 | std::string dest_path_write = "/mnt/runtime/write/" + label; |
@@ -166,13 +116,10 @@ static void run_sdcardfs(const std::string& source_path, const std::string& labe | ||
166 | 116 | // Multi-user storage is fully isolated per user, so "other" |
167 | 117 | // permissions are completely masked off. |
168 | 118 | if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid, |
169 | - AID_SDCARD_RW, 0006, derive_gid, default_normal, use_esdfs) || | |
170 | - !sdcardfs_setup_secondary(dest_path_default, source_path, dest_path_read, uid, gid, | |
171 | - multi_user, userid, AID_EVERYBODY, 0027, derive_gid, | |
172 | - default_normal, use_esdfs) || | |
173 | - !sdcardfs_setup_secondary(dest_path_default, source_path, dest_path_write, uid, gid, | |
174 | - multi_user, userid, AID_EVERYBODY, full_write ? 0007 : 0027, | |
175 | - derive_gid, default_normal, use_esdfs)) { | |
119 | + AID_SDCARD_RW, 0006, derive_gid, default_normal) || | |
120 | + !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, 0027) || | |
121 | + !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write, AID_EVERYBODY, | |
122 | + full_write ? 0007 : 0027)) { | |
176 | 123 | LOG(FATAL) << "failed to sdcardfs_setup"; |
177 | 124 | } |
178 | 125 | } else { |
@@ -180,13 +127,11 @@ static void run_sdcardfs(const std::string& source_path, const std::string& labe | ||
180 | 127 | // the Android directories are masked off to a single user |
181 | 128 | // deep inside attr_from_stat(). |
182 | 129 | if (!sdcardfs_setup(source_path, dest_path_default, uid, gid, multi_user, userid, |
183 | - AID_SDCARD_RW, 0006, derive_gid, default_normal, use_esdfs) || | |
184 | - !sdcardfs_setup_secondary(dest_path_default, source_path, dest_path_read, uid, gid, | |
185 | - multi_user, userid, AID_EVERYBODY, full_write ? 0027 : 0022, | |
186 | - derive_gid, default_normal, use_esdfs) || | |
187 | - !sdcardfs_setup_secondary(dest_path_default, source_path, dest_path_write, uid, gid, | |
188 | - multi_user, userid, AID_EVERYBODY, full_write ? 0007 : 0022, | |
189 | - derive_gid, default_normal, use_esdfs)) { | |
130 | + AID_SDCARD_RW, 0006, derive_gid, default_normal) || | |
131 | + !sdcardfs_setup_bind_remount(dest_path_default, dest_path_read, AID_EVERYBODY, | |
132 | + full_write ? 0027 : 0022) || | |
133 | + !sdcardfs_setup_bind_remount(dest_path_default, dest_path_write, AID_EVERYBODY, | |
134 | + full_write ? 0007 : 0022)) { | |
190 | 135 | LOG(FATAL) << "failed to sdcardfs_setup"; |
191 | 136 | } |
192 | 137 | } |
@@ -297,6 +242,6 @@ int main(int argc, char **argv) { | ||
297 | 242 | } |
298 | 243 | |
299 | 244 | run_sdcardfs(source_path, label, uid, gid, userid, multi_user, full_write, derive_gid, |
300 | - default_normal, !should_use_sdcardfs()); | |
245 | + default_normal); | |
301 | 246 | return 1; |
302 | 247 | } |