Merge "vold: add coldboot back and make sure it won't block booting" am: b3715cf3af
am: 5457b47f9e
am: 660006e7a4
Change-Id: I21e4ba746c99bd8c372d802f11f0bb3f36376553
This commit is contained in:
commit
a3b6d90934
1 changed files with 49 additions and 0 deletions
49
main.cpp
49
main.cpp
|
@ -36,9 +36,11 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <dirent.h>
|
||||||
#include <fs_mgr.h>
|
#include <fs_mgr.h>
|
||||||
|
|
||||||
static int process_config(VolumeManager *vm, bool* has_adoptable);
|
static int process_config(VolumeManager *vm, bool* has_adoptable);
|
||||||
|
static void coldboot(const char *path);
|
||||||
static void parse_args(int argc, char** argv);
|
static void parse_args(int argc, char** argv);
|
||||||
|
|
||||||
struct fstab *fstab;
|
struct fstab *fstab;
|
||||||
|
@ -132,6 +134,10 @@ int main(int argc, char** argv) {
|
||||||
// a deadlock between vold and init (see b/34278978 for details)
|
// a deadlock between vold and init (see b/34278978 for details)
|
||||||
property_set("vold.has_adoptable", has_adoptable ? "1" : "0");
|
property_set("vold.has_adoptable", has_adoptable ? "1" : "0");
|
||||||
|
|
||||||
|
// Do coldboot here so it won't block booting,
|
||||||
|
// also the cold boot is needed in case we have flash drive
|
||||||
|
// connected before Vold launched
|
||||||
|
coldboot("/sys/block");
|
||||||
// Eventually we'll become the monitoring thread
|
// Eventually we'll become the monitoring thread
|
||||||
while(1) {
|
while(1) {
|
||||||
pause();
|
pause();
|
||||||
|
@ -165,6 +171,49 @@ static void parse_args(int argc, char** argv) {
|
||||||
CHECK(android::vold::sFsckUntrustedContext != nullptr);
|
CHECK(android::vold::sFsckUntrustedContext != nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void do_coldboot(DIR *d, int lvl) {
|
||||||
|
struct dirent *de;
|
||||||
|
int dfd, fd;
|
||||||
|
|
||||||
|
dfd = dirfd(d);
|
||||||
|
|
||||||
|
fd = openat(dfd, "uevent", O_WRONLY | O_CLOEXEC);
|
||||||
|
if(fd >= 0) {
|
||||||
|
write(fd, "add\n", 4);
|
||||||
|
close(fd);
|
||||||
|
}
|
||||||
|
|
||||||
|
while((de = readdir(d))) {
|
||||||
|
DIR *d2;
|
||||||
|
|
||||||
|
if (de->d_name[0] == '.')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (de->d_type != DT_DIR && lvl > 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
fd = openat(dfd, de->d_name, O_RDONLY | O_DIRECTORY);
|
||||||
|
if(fd < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
d2 = fdopendir(fd);
|
||||||
|
if(d2 == 0)
|
||||||
|
close(fd);
|
||||||
|
else {
|
||||||
|
do_coldboot(d2, lvl + 1);
|
||||||
|
closedir(d2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void coldboot(const char *path) {
|
||||||
|
DIR *d = opendir(path);
|
||||||
|
if(d) {
|
||||||
|
do_coldboot(d, 0);
|
||||||
|
closedir(d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int process_config(VolumeManager *vm, bool* has_adoptable) {
|
static int process_config(VolumeManager *vm, bool* has_adoptable) {
|
||||||
std::string path(android::vold::DefaultFstabPath());
|
std::string path(android::vold::DefaultFstabPath());
|
||||||
fstab = fs_mgr_read_fstab(path.c_str());
|
fstab = fs_mgr_read_fstab(path.c_str());
|
||||||
|
|
Loading…
Reference in a new issue