[PATCHv2,04/12] installer: Ensure to always create the /boot directory.

Message ID 20240323105629.371511-4-stefan.schantl@ipfire.org
State Staged
Commit fbeac0960ae9fab5bbe4ddf1518c6514be5873de
Headers
Series [PATCHv2,01/12] btrfs-progs: New package |

Commit Message

Stefan Schantl March 23, 2024, 10:56 a.m. UTC
  Ensure to always create the /boot directory during the mounting
of the various created file systems. If the /boot directory does not
exist some following mount operations could not be performed correctly
and the installation/mounting will fail.

Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
 src/installer/hw.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
  

Patch

diff --git a/src/installer/hw.c b/src/installer/hw.c
index 4d214c152..969c47508 100644
--- a/src/installer/hw.c
+++ b/src/installer/hw.c
@@ -904,10 +904,16 @@  int hw_mount_filesystems(struct hw_destination* dest, const char* prefix) {
 		return r;
 
 	// boot
-	if (*dest->part_boot) {
-		snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT);
-		mkdir(target, S_IRWXU|S_IRWXG|S_IRWXO);
+	snprintf(target, sizeof(target), "%s%s", prefix, HW_PATH_BOOT);
+	r = mkdir(target, S_IRWXU|S_IRWXG|S_IRWXO);
+
+	if (r) {
+		hw_umount_filesystems(dest, prefix);
 
+		return r;
+	}
+
+	if (*dest->part_boot) {
 		r = hw_mount(dest->part_boot, target, filesystem, 0);
 		if (r) {
 			hw_umount_filesystems(dest, prefix);