From patchwork Fri Mar 15 19:14:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7635 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4TxDTn4h13z3wv4 for ; Fri, 15 Mar 2024 19:15:09 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4TxDTl5SXHzFMB; Fri, 15 Mar 2024 19:15:07 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4TxDTl518Tz32nQ; Fri, 15 Mar 2024 19:15:07 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) client-signature ECDSA (secp384r1)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4TxDTb4FGcz32nQ for ; Fri, 15 Mar 2024 19:14:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4TxDTY3lHyzFKw; Fri, 15 Mar 2024 19:14:57 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1710530097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l0LDWikR5/60kBQ0JK4ZWqrzLZI9v1y+2TsEYOv1AYU=; b=ifjckVrl9rb6cs93zl2DjqjBmfMC3APH0Ax6umIC4z7wOZUH7JqQZoiyr0nxkPR0U554sH +A42QbAppThOA2Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1710530097; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=l0LDWikR5/60kBQ0JK4ZWqrzLZI9v1y+2TsEYOv1AYU=; b=jRZHvHXOW069zi0sPgYKkFCQaDyV8sxB/NzoUojwH3qX/xoE0P/dr4RvHjNmpakqeNTMsw KtbCPAIE8hsr5YuPf1R30xKFaGqDJ+/fHZNX8iS65swAHBwxfdvyZddf9tJJzY1nw2Sj34 fvXC2hyDB4+97yhLcawIq5bDDTibzN9Y4416rjH/eW4TJ86Y4Lx4RGuH305rSZLiazVcdY GXZ9o0c5mLGs6Bs6ph36R+BOOFjzp1v+AEEQ34NGxZv7Qsy+hr7KamSX/Xk7eUHDw8RloY iI5JlvrxqPSxrWxFM3wqkJ+9Rs71vKdOuye6J/cZJn3AHgooZTvHvmyEvswx1g== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 11/17] installer: Add code to proper unmount the BTRFS layout Date: Fri, 15 Mar 2024 20:14:36 +0100 Message-Id: <20240315191442.3951-12-stefan.schantl@ipfire.org> In-Reply-To: <20240315191442.3951-1-stefan.schantl@ipfire.org> References: <20240315191442.3951-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 Message-ID-Hash: 3IB7EEWWENKCRRZJZEQCNDTEVS3GMB3P X-Message-ID-Hash: 3IB7EEWWENKCRRZJZEQCNDTEVS3GMB3P X-MailFrom: stefan.schantl@ipfire.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: IPFire development talk Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Signed-off-by: Stefan Schantl --- src/installer/hw.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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];