Support fs mount options.
Change-Id: I8b0dc79dd054c4d1af599d9b68b5478196bdd183
This commit is contained in:
parent
33fd0d0a70
commit
e8bc2c808c
4
common.h
4
common.h
@ -113,6 +113,10 @@ typedef struct {
|
||||
// == "ext4" or "vfat" and mounting
|
||||
// 'device' fails
|
||||
const char* fs_type2;
|
||||
|
||||
const char* fs_options;
|
||||
|
||||
const char* fs_options2;
|
||||
} Volume;
|
||||
|
||||
#endif // RECOVERY_COMMON_H
|
||||
|
@ -1026,6 +1026,9 @@ int bml_check_volume(const char *path) {
|
||||
void process_volumes() {
|
||||
create_fstab();
|
||||
|
||||
return;
|
||||
|
||||
// dead code.
|
||||
if (device_flash_type() != BML)
|
||||
return;
|
||||
|
||||
|
29
roots.c
29
roots.c
@ -63,6 +63,8 @@ void load_volume_table() {
|
||||
// mounting the first one fails.
|
||||
char* device2 = strtok(NULL, " \t\n");
|
||||
char* fs_type2 = strtok(NULL, " \t\n");
|
||||
char* fs_options = strtok(NULL, " \t\n");
|
||||
char* fs_options2 = strtok(NULL, " \t\n");
|
||||
|
||||
if (mount_point && fs_type && device) {
|
||||
while (num_volumes >= alloc) {
|
||||
@ -75,6 +77,13 @@ void load_volume_table() {
|
||||
device_volumes[num_volumes].device2 =
|
||||
(device2 != NULL && strcmp(device2, "NULL") != 0) ? strdup(device2) : NULL;
|
||||
device_volumes[num_volumes].fs_type2 = fs_type2 != NULL ? strdup(fs_type) : NULL;
|
||||
|
||||
if (fs_type2 != NULL) {
|
||||
char *temp;
|
||||
temp = fs_options2;
|
||||
fs_options2 = fs_options;
|
||||
fs_options = temp;
|
||||
}
|
||||
++num_volumes;
|
||||
} else {
|
||||
LOGE("skipping malformed recovery.fstab line: %s\n", original);
|
||||
@ -107,11 +116,19 @@ Volume* volume_for_path(const char* path) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int try_mount(const char* device, const char* mount_point, const char* fs_type) {
|
||||
int try_mount(const char* device, const char* mount_point, const char* fs_type, const char* fs_options) {
|
||||
if (device == NULL || mount_point == NULL || fs_type == NULL)
|
||||
return -1;
|
||||
int ret = mount(device, mount_point, fs_type,
|
||||
int ret = 0;
|
||||
if (fs_options == NULL) {
|
||||
ret = mount(device, mount_point, fs_type,
|
||||
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "");
|
||||
}
|
||||
else {
|
||||
char mount_cmd[PATH_MAX];
|
||||
sprintf(mount_cmd, "mount -o%s %s %s", fs_options, device, mount_point);
|
||||
ret = __system(mount_cmd);
|
||||
}
|
||||
if (ret == 0)
|
||||
return 0;
|
||||
LOGW("failed to mount %s (%s)\n", device, strerror(errno));
|
||||
@ -160,13 +177,13 @@ int ensure_path_mounted(const char* path) {
|
||||
strcmp(v->fs_type, "ext3") == 0 ||
|
||||
strcmp(v->fs_type, "vfat") == 0) {
|
||||
// try fs type 2 first
|
||||
if ((result = try_mount(v->device, v->mount_point, v->fs_type)) == 0)
|
||||
if ((result = try_mount(v->device, v->mount_point, v->fs_type, v->fs_options)) == 0)
|
||||
return 0;
|
||||
if ((result = try_mount(v->device2, v->mount_point, v->fs_type)) == 0)
|
||||
if ((result = try_mount(v->device2, v->mount_point, v->fs_type, v->fs_options)) == 0)
|
||||
return 0;
|
||||
if ((result = try_mount(v->device, v->mount_point, v->fs_type2)) == 0)
|
||||
if ((result = try_mount(v->device, v->mount_point, v->fs_type2, v->fs_options2)) == 0)
|
||||
return 0;
|
||||
if ((result = try_mount(v->device2, v->mount_point, v->fs_type2)) == 0)
|
||||
if ((result = try_mount(v->device2, v->mount_point, v->fs_type2, v->fs_options2)) == 0)
|
||||
return 0;
|
||||
return result;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user