Android-x86
Fork

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-vold: コミット

system/vold


コミットメタ情報

リビジョン2cc005de01ad822ea8c8904a32738a38b5bacdf6 (tree)
日時2017-08-24 23:49:32
作者Jani Lusikka <jani.lusikka@gmai...>
コミッターAdrian DC

ログメッセージ

vold: Mount ext4/f2fs portable storage with sdcard_posix

This commit is a forward port of following commits:

Author: Michael Stucki <mundaun@gmx.ch>
Change-Id: Ia34ad91444951e62f6d17374f480dcbdfa34cca3

Author: Tom Marshall <tdm@cyngn.com>
Change-Id: I05d9b57cc28ffd1f8deb8148d81c7f6fad0aa8db

Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Change-Id: I1364f37018b25d79b1826c85849def64e868d72f

Author: Pawit Pornkitprasan <p.pawit@gmail.com>
Change-Id: I873af4dc2309d3d0942ce466b8acf8158abb85ae

Author: Jorge Ruesga <jorge@ruesga.com>
Change-Id: Ic0bb314b30e42489c45caec29d35d6896c9849eb

Signed-off-by: Michael Bestas <mikeioannina@cyanogenmod.org>
Change-Id: I9699643987c53d8e2538720f33da28de35230dfe

変更サマリ

差分

--- a/PublicVolume.cpp
+++ b/PublicVolume.cpp
@@ -152,9 +152,9 @@ status_t PublicVolume::doMount() {
152152 ret = exfat::Mount(mDevPath, mRawPath, false, false, false,
153153 AID_MEDIA_RW, AID_MEDIA_RW, 0007);
154154 } else if (mFsType == "ext4") {
155- ret = ext4::Mount(mDevPath, mRawPath, false, false, true, mMntOpts);
155+ ret = ext4::Mount(mDevPath, mRawPath, false, false, true, mMntOpts, true);
156156 } else if (mFsType == "f2fs") {
157- ret = f2fs::Mount(mDevPath, mRawPath, mMntOpts);
157+ ret = f2fs::Mount(mDevPath, mRawPath, mMntOpts, true);
158158 } else if (mFsType == "ntfs") {
159159 ret = ntfs::Mount(mDevPath, mRawPath, false, false, false,
160160 AID_MEDIA_RW, AID_MEDIA_RW, 0007, true);
--- a/fs/Ext4.cpp
+++ b/fs/Ext4.cpp
@@ -36,7 +36,7 @@
3636 #include <linux/kdev_t.h>
3737
3838 #define LOG_TAG "Vold"
39-
39+#include <private/android_filesystem_config.h>
4040 #include <android-base/logging.h>
4141 #include <android-base/stringprintf.h>
4242 #include <cutils/log.h>
@@ -130,13 +130,21 @@ status_t Check(const std::string& source, const std::string& target, bool truste
130130 }
131131
132132 status_t Mount(const std::string& source, const std::string& target, bool ro,
133- bool remount, bool executable, const std::string& opts /* = "" */) {
133+ bool remount, bool executable, const std::string& opts /* = "" */, bool portable) {
134134 int rc;
135135 unsigned long flags;
136136
137+ std::string data(opts);
138+
139+ if (portable) {
140+ if (!data.empty()) {
141+ data += ",";
142+ }
143+ data += "context=u:object_r:sdcard_posix:s0";
144+ }
137145 const char* c_source = source.c_str();
138146 const char* c_target = target.c_str();
139- const char* c_opts = opts.c_str();
147+ const char* c_data = data.c_str();
140148
141149 flags = MS_NOATIME | MS_NODEV | MS_NOSUID | MS_DIRSYNC;
142150
@@ -144,12 +152,16 @@ status_t Mount(const std::string& source, const std::string& target, bool ro,
144152 flags |= (ro ? MS_RDONLY : 0);
145153 flags |= (remount ? MS_REMOUNT : 0);
146154
147- rc = mount(c_source, c_target, "ext4", flags, c_opts);
155+ rc = mount(c_source, c_target, "ext4", flags, c_data);
156+ if (portable && rc == 0) {
157+ chown(c_target, AID_MEDIA_RW, AID_MEDIA_RW);
158+ chmod(c_target, 0755);
159+ }
148160
149161 if (rc && errno == EROFS) {
150162 SLOGE("%s appears to be a read only filesystem - retrying mount RO", c_source);
151163 flags |= MS_RDONLY;
152- rc = mount(c_source, c_target, "ext4", flags, NULL);
164+ rc = mount(c_source, c_target, "ext4", flags, c_data);
153165 }
154166
155167 return rc;
--- a/fs/Ext4.h
+++ b/fs/Ext4.h
@@ -29,7 +29,7 @@ bool IsSupported();
2929
3030 status_t Check(const std::string& source, const std::string& target, bool trusted);
3131 status_t Mount(const std::string& source, const std::string& target, bool ro,
32- bool remount, bool executable, const std::string& opts = "");
32+ bool remount, bool executable, const std::string& opts = "", bool portable = false);
3333 status_t Format(const std::string& source, unsigned long numSectors,
3434 const std::string& target);
3535 status_t Resize(const std::string& source, unsigned long numSectors);
--- a/fs/F2fs.cpp
+++ b/fs/F2fs.cpp
@@ -19,10 +19,10 @@
1919
2020 #include <android-base/logging.h>
2121 #include <android-base/stringprintf.h>
22-
22+#include <private/android_filesystem_config.h>
2323 #include <vector>
2424 #include <string>
25-
25+#include <sys/stat.h>
2626 #include <sys/mount.h>
2727
2828 using android::base::StringPrintf;
@@ -49,17 +49,32 @@ status_t Check(const std::string& source, bool trusted) {
4949 return ForkExecvp(cmd, trusted ? sFsckContext : sFsckUntrustedContext);
5050 }
5151
52-status_t Mount(const std::string& source, const std::string& target, const std::string& opts /* = "" */) {
52+status_t Mount(const std::string& source, const std::string& target, const std::string& opts /* = "" */, bool portable) {
53+
54+ std::string data(opts);
55+
56+ if (portable) {
57+ if (!data.empty()) {
58+ data += ",";
59+ }
60+ data += "context=u:object_r:sdcard_posix:s0";
61+ }
62+
5363 const char* c_source = source.c_str();
5464 const char* c_target = target.c_str();
55- const char* c_opts = opts.c_str();
65+ const char* c_data = data.c_str();
5666 unsigned long flags = MS_NOATIME | MS_NODEV | MS_NOSUID | MS_DIRSYNC;
5767
58- int res = mount(c_source, c_target, "f2fs", flags, c_opts);
68+ int res = mount(c_source, c_target, "f2fs", flags, c_data);
69+ if (portable && res == 0) {
70+ chown(c_target, AID_MEDIA_RW, AID_MEDIA_RW);
71+ chmod(c_target, 0755);
72+ }
73+
5974 if (res != 0) {
6075 PLOG(ERROR) << "Failed to mount " << source;
6176 if (errno == EROFS) {
62- res = mount(c_source, c_target, "f2fs", flags | MS_RDONLY, NULL);
77+ res = mount(c_source, c_target, "f2fs", flags | MS_RDONLY, c_data);
6378 if (res != 0) {
6479 PLOG(ERROR) << "Failed to mount read-only " << source;
6580 }
--- a/fs/F2fs.h
+++ b/fs/F2fs.h
@@ -28,7 +28,7 @@ namespace f2fs {
2828 bool IsSupported();
2929
3030 status_t Check(const std::string& source, bool trusted);
31-status_t Mount(const std::string& source, const std::string& target, const std::string& opts = "");
31+status_t Mount(const std::string& source, const std::string& target, const std::string& opts = "", bool portable = false);
3232 status_t Format(const std::string& source);
3333
3434 } // namespace f2fs
旧リポジトリブラウザで表示