]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
installer: Add code to proper unmount the BTRFS layout
authorStefan Schantl <stefan.schantl@ipfire.org>
Mon, 26 Feb 2024 17:41:27 +0000 (18:41 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Mon, 26 Feb 2024 17:41:27 +0000 (18:41 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
src/installer/hw.c

index 1c4adc24b8d41cfb304152b3de7d839b9f8a9f93..b5b853e92daceb000683328029941c8de7d1ca43 100644 (file)
@@ -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];