|
|
|
@ -18,6 +18,11 @@
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
|
#include <fcntl.h>
|
|
|
|
|
#include <dirent.h>
|
|
|
|
|
|
|
|
|
|
#define LOG_TAG "Vold"
|
|
|
|
|
|
|
|
|
@ -29,6 +34,7 @@
|
|
|
|
|
#include "DeviceVolume.h"
|
|
|
|
|
|
|
|
|
|
static int process_config(VolumeManager *vm);
|
|
|
|
|
static void coldboot(const char *path);
|
|
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
|
|
|
|
|
@ -68,6 +74,8 @@ int main() {
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
coldboot("/sys/block");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Now that we're up, we can respond to commands
|
|
|
|
|
*/
|
|
|
|
@ -85,6 +93,51 @@ int main() {
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void do_coldboot(DIR *d, int lvl)
|
|
|
|
|
{
|
|
|
|
|
struct dirent *de;
|
|
|
|
|
int dfd, fd;
|
|
|
|
|
|
|
|
|
|
dfd = dirfd(d);
|
|
|
|
|
|
|
|
|
|
fd = openat(dfd, "uevent", O_WRONLY);
|
|
|
|
|
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) {
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int n = 0;
|
|
|
|
|