From: Stefan Schantl Date: Mon, 26 Feb 2024 17:41:27 +0000 (+0100) Subject: installer: Add code to proper unmount the BTRFS layout X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=767fdab6d794ce4b5f66bca7db735e8aed785a39;p=people%2Fstevee%2Fipfire-2.x.git installer: Add code to proper unmount the BTRFS layout Signed-off-by: Stefan Schantl --- diff --git a/src/installer/hw.c b/src/installer/hw.c index 1c4adc24b..b5b853e92 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1106,13 +1106,36 @@ int hw_umount_filesystems(struct hw_destination* dest, const char* prefix) { return -1; // root - r = hw_umount(prefix, NULL); + if(dest->filesystem == HW_FS_BTRFS) { + r = hw_umount_btrfs_layout(); + } else { + r = hw_umount(prefix, NULL); + } + if (r) return -1; return 0; } +int hw_umount_btrfs_layout() { + char path[STRING_SIZE]; + int r; + + // Reverse loop through the array of known subvolumes. + for ( int i = LEN(btrfs_subvolumes); i >= 0; i-- ) { + snprintf(path, sizeof(path), "%s%s", DESTINATION_MOUNT_PATH, btrfs_subvolumes[i][1]); + + // umount the subvolume. + r = hw_umount(path, NULL); + + if (r) + return r; + } + + return 0; +} + int hw_destroy_raid_superblocks(const struct hw_destination* dest, const char* output) { char cmd[STRING_SIZE];