Skip to content

Commit 43e8380

Browse files
committed
Multiple trials to unmount OPK_MOUNTPOINT
1 parent f97f593 commit 43e8380

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

opkrun.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,27 @@ int main(int argc, char **argv)
432432
waitpid(son, &status, 0);
433433

434434
chdir("/");
435-
umount(OPK_MOUNTPOINT);
435+
436+
/** Multiple trials to unmount OPK_MOUNTPOINT */
437+
#define MAX_UMOUNT_TRIALS 100
438+
int retries = MAX_UMOUNT_TRIALS;
439+
int res = -1;
440+
while (retries && res){
441+
res = umount(OPK_MOUNTPOINT);
442+
/*printf("Res %d umounting %s, trial %d/%d\n",
443+
res, OPK_MOUNTPOINT, MAX_UMOUNT_TRIALS-retries+1, MAX_UMOUNT_TRIALS);*/
444+
445+
if(res)
446+
usleep(50*1000);
447+
448+
retries--;
449+
}
450+
451+
if(!retries){
452+
printf("Error(%d) umounting %s\n", res, OPK_MOUNTPOINT);
453+
}
454+
455+
/** Voluntarily commented */
436456
//rmdir(OPK_MOUNTPOINT);
437457

438458
ioctl(loopfd, LOOP_CLR_FD, (void *)0);

0 commit comments

Comments
 (0)