[11/17] installer: Add code to proper unmount the BTRFS layout
Commit Message
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
---
src/installer/hw.c | 25 ++++++++++++++++++++++++-
1 file changed, 24 insertions(+), 1 deletion(-)
@@ -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];