Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit 96df7e6

Browse files
committed
do not ignore errors when failing to set up container fs mapping
Signed-off-by: Peng Tao <bergwolf@gmail.com>
1 parent ab30fff commit 96df7e6

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/container.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static int container_setup_volume(struct hyper_container *container)
203203
if (st.st_mode & S_IFDIR) {
204204
if (hyper_mkdir(mountpoint, 0755) < 0) {
205205
perror("create map dir failed");
206-
continue;
206+
return -1;
207207
}
208208
if (map->docker) {
209209
/* converted from volume */
@@ -212,28 +212,30 @@ static int container_setup_volume(struct hyper_container *container)
212212
if (container->initialize &&
213213
(container_populate_volume(mountpoint, volume) < 0)) {
214214
fprintf(stderr, "fail to populate volume %s\n", mountpoint);
215-
continue;
215+
return -1;
216216
}
217217
}
218218
} else {
219219
int fd = open(mountpoint, O_CREAT|O_WRONLY, 0755);
220220
if (fd < 0) {
221221
perror("create map file failed");
222-
continue;
222+
return -1;
223223
}
224224
close(fd);
225225
}
226226

227227
if (mount(src, mountpoint, NULL, MS_BIND, NULL) < 0) {
228228
perror("mount fsmap failed");
229-
continue;
229+
return -1;
230230
}
231231

232232
if (map->readonly == 0)
233233
continue;
234234

235-
if (mount(src, mountpoint, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0)
235+
if (mount(src, mountpoint, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL) < 0) {
236236
perror("mount fsmap failed");
237+
return -1;
238+
}
237239
}
238240

239241
return 0;

0 commit comments

Comments
 (0)