Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

system-vold: Commit

system/vold


Commit MetaInfo

Revision0b31eb4189975aa2546683396f760ac8fb354e37 (tree)
Time2019-03-21 00:19:02
AuthorChih-Wei Huang <cwhuang@linu...>
CommiterChih-Wei Huang

Log Message

vold3: support the old SDCARD=xxx function

By specifying SDCARD=xxx in kernel cmdline, vold will try to mount
that disk or partition as a sdcard. This is an old function we've
added to vold 2.0. Now re-implement it in vold 3.0. Some people
still like and use it.

Change Summary

Incremental Difference

--- a/main.cpp
+++ b/main.cpp
@@ -24,6 +24,7 @@
2424 #include "cryptfs.h"
2525 #include "sehandle.h"
2626
27+#include <android-base/file.h>
2728 #include <android-base/logging.h>
2829 #include <android-base/properties.h>
2930 #include <android-base/stringprintf.h>
@@ -267,5 +268,35 @@ static int process_config(VolumeManager* vm, bool* has_adoptable, bool* has_quot
267268 fstype, mntopts)));
268269 }
269270 }
271+
272+ std::string cmdline;
273+ if (android::base::ReadFileToString("/proc/cmdline", &cmdline)) {
274+ size_t pos = cmdline.find("SDCARD=");
275+ if (pos != std::string::npos) {
276+ std::string sdcard = cmdline.substr(pos + 7);
277+ sdcard = sdcard.substr(0, sdcard.find_first_of(" \n"));
278+ if (!sdcard.empty()) {
279+ int partnum = -1;
280+ if (access(std::string("/sys/block/" + sdcard).c_str(), X_OK)) { // not a disk
281+ auto d = std::find_if_not(sdcard.rbegin(), sdcard.rend(), ::isdigit);
282+ pos = std::distance(d, sdcard.rend());
283+ if (pos != sdcard.length()) {
284+ partnum = std::stoi(sdcard.substr(pos));
285+ sdcard = sdcard.substr(0, pos);
286+ if (sdcard.find("mmcblk") != std::string::npos) {
287+ // exclude the last 'p'
288+ sdcard = sdcard.substr(0, pos - 1);
289+ }
290+ }
291+ }
292+ vm->addDiskSource(std::shared_ptr<VolumeManager::DiskSource>(
293+ new VolumeManager::DiskSource("/devices/*/" + sdcard, sdcard,
294+ partnum, android::vold::Disk::Flags::kAdoptable, "auto", "")));
295+ *has_adoptable = true;
296+ LOG(INFO) << "Add SDCARD=" << sdcard << " partnum=" << partnum;
297+ }
298+ }
299+ }
300+
270301 return 0;
271302 }
Show on old repository browser