Loading updater/install.c +18 −5 Original line number Original line Diff line number Diff line Loading @@ -91,17 +91,28 @@ char* PrintSha1(const uint8_t* digest) { // fs_type="ext4" partition_type="EMMC" location=device // fs_type="ext4" partition_type="EMMC" location=device Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { char* result = NULL; char* result = NULL; if (argc != 4) { if (argc != 4 && argc != 5) { return ErrorAbort(state, "%s() expects 4 args, got %d", name, argc); return ErrorAbort(state, "%s() expects 4-5 args, got %d", name, argc); } } char* fs_type; char* fs_type; char* partition_type; char* partition_type; char* location; char* location; char* mount_point; char* mount_point; char* mount_options; bool has_mount_options; if (argc == 5) { has_mount_options = true; if (ReadArgs(state, argv, 5, &fs_type, &partition_type, &location, &mount_point, &mount_options) < 0) { return NULL; } } else { has_mount_options = false; if (ReadArgs(state, argv, 4, &fs_type, &partition_type, if (ReadArgs(state, argv, 4, &fs_type, &partition_type, &location, &mount_point) < 0) { &location, &mount_point) < 0) { return NULL; return NULL; } } } if (strlen(fs_type) == 0) { if (strlen(fs_type) == 0) { ErrorAbort(state, "fs_type argument to %s() can't be empty", name); ErrorAbort(state, "fs_type argument to %s() can't be empty", name); Loading Loading @@ -154,7 +165,8 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { result = mount_point; result = mount_point; } else { } else { if (mount(location, mount_point, fs_type, if (mount(location, mount_point, fs_type, MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") < 0) { MS_NOATIME | MS_NODEV | MS_NODIRATIME, has_mount_options ? mount_options : "") < 0) { printf("%s: failed to mount %s at %s: %s\n", printf("%s: failed to mount %s at %s: %s\n", name, location, mount_point, strerror(errno)); name, location, mount_point, strerror(errno)); result = strdup(""); result = strdup(""); Loading @@ -168,6 +180,7 @@ done: free(partition_type); free(partition_type); free(location); free(location); if (result != mount_point) free(mount_point); if (result != mount_point) free(mount_point); if (has_mount_options) free(mount_options); return StringValue(result); return StringValue(result); } } Loading Loading
updater/install.c +18 −5 Original line number Original line Diff line number Diff line Loading @@ -91,17 +91,28 @@ char* PrintSha1(const uint8_t* digest) { // fs_type="ext4" partition_type="EMMC" location=device // fs_type="ext4" partition_type="EMMC" location=device Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { char* result = NULL; char* result = NULL; if (argc != 4) { if (argc != 4 && argc != 5) { return ErrorAbort(state, "%s() expects 4 args, got %d", name, argc); return ErrorAbort(state, "%s() expects 4-5 args, got %d", name, argc); } } char* fs_type; char* fs_type; char* partition_type; char* partition_type; char* location; char* location; char* mount_point; char* mount_point; char* mount_options; bool has_mount_options; if (argc == 5) { has_mount_options = true; if (ReadArgs(state, argv, 5, &fs_type, &partition_type, &location, &mount_point, &mount_options) < 0) { return NULL; } } else { has_mount_options = false; if (ReadArgs(state, argv, 4, &fs_type, &partition_type, if (ReadArgs(state, argv, 4, &fs_type, &partition_type, &location, &mount_point) < 0) { &location, &mount_point) < 0) { return NULL; return NULL; } } } if (strlen(fs_type) == 0) { if (strlen(fs_type) == 0) { ErrorAbort(state, "fs_type argument to %s() can't be empty", name); ErrorAbort(state, "fs_type argument to %s() can't be empty", name); Loading Loading @@ -154,7 +165,8 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) { result = mount_point; result = mount_point; } else { } else { if (mount(location, mount_point, fs_type, if (mount(location, mount_point, fs_type, MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") < 0) { MS_NOATIME | MS_NODEV | MS_NODIRATIME, has_mount_options ? mount_options : "") < 0) { printf("%s: failed to mount %s at %s: %s\n", printf("%s: failed to mount %s at %s: %s\n", name, location, mount_point, strerror(errno)); name, location, mount_point, strerror(errno)); result = strdup(""); result = strdup(""); Loading @@ -168,6 +180,7 @@ done: free(partition_type); free(partition_type); free(location); free(location); if (result != mount_point) free(mount_point); if (result != mount_point) free(mount_point); if (has_mount_options) free(mount_options); return StringValue(result); return StringValue(result); } } Loading