Skip to content

Commit 168f777

Browse files
Michael RungeIliyan Malchev
authored andcommitted
Allow passing of mount args to mountFn
Bug: 18079773 Bug: 18092222 Change-Id: Ifc3f3e123de729dfbb2f49414b3207afa96268d5
1 parent 473967d commit 168f777

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

updater/install.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,16 +91,27 @@ char* PrintSha1(const uint8_t* digest) {
9191
// fs_type="ext4" partition_type="EMMC" location=device
9292
Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) {
9393
char* result = NULL;
94-
if (argc != 4) {
95-
return ErrorAbort(state, "%s() expects 4 args, got %d", name, argc);
94+
if (argc != 4 && argc != 5) {
95+
return ErrorAbort(state, "%s() expects 4-5 args, got %d", name, argc);
9696
}
9797
char* fs_type;
9898
char* partition_type;
9999
char* location;
100100
char* mount_point;
101-
if (ReadArgs(state, argv, 4, &fs_type, &partition_type,
101+
char* mount_options;
102+
bool has_mount_options;
103+
if (argc == 5) {
104+
has_mount_options = true;
105+
if (ReadArgs(state, argv, 5, &fs_type, &partition_type,
106+
&location, &mount_point, &mount_options) < 0) {
107+
return NULL;
108+
}
109+
} else {
110+
has_mount_options = false;
111+
if (ReadArgs(state, argv, 4, &fs_type, &partition_type,
102112
&location, &mount_point) < 0) {
103-
return NULL;
113+
return NULL;
114+
}
104115
}
105116

106117
if (strlen(fs_type) == 0) {
@@ -154,7 +165,8 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) {
154165
result = mount_point;
155166
} else {
156167
if (mount(location, mount_point, fs_type,
157-
MS_NOATIME | MS_NODEV | MS_NODIRATIME, "") < 0) {
168+
MS_NOATIME | MS_NODEV | MS_NODIRATIME,
169+
has_mount_options ? mount_options : "") < 0) {
158170
printf("%s: failed to mount %s at %s: %s\n",
159171
name, location, mount_point, strerror(errno));
160172
result = strdup("");
@@ -168,6 +180,7 @@ Value* MountFn(const char* name, State* state, int argc, Expr* argv[]) {
168180
free(partition_type);
169181
free(location);
170182
if (result != mount_point) free(mount_point);
183+
if (has_mount_options) free(mount_options);
171184
return StringValue(result);
172185
}
173186

0 commit comments

Comments
 (0)