Skip to content

Commit 0cec807

Browse files
author
Jiri Svoboda
committed
Unmount destination volume and delete mount point on installation failure.
1 parent 21cd0c8 commit 0cec807

File tree

1 file changed

+22
-7
lines changed

1 file changed

+22
-7
lines changed

uspace/app/sysinst/sysinst.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,11 @@ static errno_t sysinst_setup_sysvol(sysinst_t *sysinst)
591591
/* Copy initial configuration files */
592592
rc = futil_rcopy_contents(sysinst->futil, CFG_FILES_SRC,
593593
CFG_FILES_DEST);
594-
if (rc != EOK)
594+
if (rc != EOK) {
595+
sysinst_error(sysinst, "Error copying initial configuration "
596+
"files.");
595597
return rc;
598+
}
596599

597600
return EOK;
598601
error:
@@ -612,8 +615,11 @@ static errno_t sysinst_copy_boot_files(sysinst_t *sysinst)
612615
log_msg(LOG_DEFAULT, LVL_NOTE,
613616
"sysinst_copy_boot_files(): copy bootloader files");
614617
rc = futil_rcopy_contents(sysinst->futil, BOOT_FILES_SRC, MOUNT_POINT);
615-
if (rc != EOK)
618+
if (rc != EOK) {
619+
sysinst_error(sysinst, "Error copying bootloader "
620+
"files.");
616621
return rc;
622+
}
617623

618624
sysinst_debug(sysinst, "sysinst_copy_boot_files(): OK");
619625
return EOK;
@@ -982,32 +988,37 @@ static errno_t sysinst_restart(sysinst_t *sysinst)
982988
static errno_t sysinst_install(sysinst_t *sysinst, const char *dev)
983989
{
984990
errno_t rc;
991+
bool clean_dev = false;
985992

986993
sysinst_action(sysinst, "Creating device label and file system.");
987994

988995
rc = sysinst_label_dev(sysinst, dev);
989996
if (rc != EOK)
990-
return rc;
997+
goto error;
998+
999+
clean_dev = true;
9911000

9921001
sysinst_action(sysinst, "Creating system directory structure.");
9931002
rc = sysinst_setup_sysvol(sysinst);
9941003
if (rc != EOK)
995-
return rc;
1004+
goto error;
9961005

9971006
sysinst_action(sysinst, "Copying boot files.");
9981007
rc = sysinst_copy_boot_files(sysinst);
9991008
if (rc != EOK)
1000-
return rc;
1009+
goto error;
10011010

10021011
sysinst_action(sysinst, "Configuring the system.");
10031012
rc = sysinst_customize_initrd(sysinst);
10041013
if (rc != EOK)
1005-
return rc;
1014+
goto error;
10061015

10071016
sysinst_action(sysinst, "Finishing system volume.");
10081017
rc = sysinst_finish_dev(sysinst);
10091018
if (rc != EOK)
1010-
return rc;
1019+
goto error;
1020+
1021+
clean_dev = false;
10111022

10121023
sysinst_action(sysinst, "Installing boot blocks.");
10131024
rc = sysinst_copy_boot_blocks(sysinst, dev);
@@ -1020,6 +1031,10 @@ static errno_t sysinst_install(sysinst_t *sysinst, const char *dev)
10201031
return rc;
10211032

10221033
return EOK;
1034+
error:
1035+
if (clean_dev)
1036+
(void)sysinst_finish_dev(sysinst);
1037+
return rc;
10231038
}
10241039

10251040
/** Installation fibril.

0 commit comments

Comments
 (0)