From patchwork Fri Mar 15 19:14:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 7636 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 4TxDTs5gpYz3wnw for ; Fri, 15 Mar 2024 19:15:13 +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 4TxDTl6n1yzFMD; 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 4TxDTl6F0Jz32pt; 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 4TxDTb6g58z32pt 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 4TxDTY6TPMzFLZ; 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=1710530098; 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=9AgTXShAyT8JL2at323MnwAX+i/KLkrTjcFillUcphc=; b=/tdOkvIEUCEQ7aGDowYYSxa+7Pgv/U2+DLLGw/RlBH/2sgxJZVWNwwmk8YhTzt2axFKZZL 5KVZiwgGsj/HBUAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1710530098; 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=9AgTXShAyT8JL2at323MnwAX+i/KLkrTjcFillUcphc=; b=Du9giqWuxVeCUf6MRqjyFTHC2ySe1viIWi/a64PKZ2k4DRf2bCogwyrbVmlBUTkJtI+D+S vkCj35fQCiEcpp0KXkmS0eiBKGd5ZT23RmoxQKioZqpe/OVZRsIItT5PgIRUznQah5xwh6 HCeXaPBkyMl+1oJiQ31gOA76BANXSD6CH3o2mj5TUiWmg1MGoQS5Nf8SlldNKXJxGHa79j J3nhD9mBMMy0KHV7I+7GeUIhjvTGMPE+cjpmo3QAQsDOi3J4yHr7cX1LYhIW5WFfnd0rdP rce5L8aALlTWZgaTmtMjmBcnWfgL9A6vjL/RpK1egbMgkzdIcO2B2YIgY4nIkg== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH 12/17] installer: Add code to correctly write the fstab when installing on BTRFS Date: Fri, 15 Mar 2024 20:14:37 +0100 Message-Id: <20240315191442.3951-13-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: LOGQVZVAQKXRUBNPWDHX26DUDVB7E5KG X-Message-ID-Hash: LOGQVZVAQKXRUBNPWDHX26DUDVB7E5KG 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/installer/hw.c b/src/installer/hw.c index b5b853e92..26c473e9c 100644 --- a/src/installer/hw.c +++ b/src/installer/hw.c @@ -1260,6 +1260,7 @@ int hw_write_fstab(struct hw_destination* dest) { return -1; char* uuid = NULL; + char mount_options[STRING_SIZE]; // boot if (*dest->part_boot) { @@ -1295,7 +1296,16 @@ int hw_write_fstab(struct hw_destination* dest) { // root uuid = hw_get_uuid(dest->part_root); if (uuid) { - fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + if(dest->filesystem == HW_FS_BTRFS) { + // Loop through the array of known BTRFS subvolumes + for ( int i = 0; i < LEN(btrfs_subvolumes); i++ ) { + snprintf(mount_options, sizeof(mount_options), "defaults,%s,subvol=%s", BTRFS_MOUNT_OPTIONS, btrfs_subvolumes[i][0]); + fprintf(f, FSTAB_FMT, uuid, btrfs_subvolumes[i][1], "btrfs", mount_options, 1, 1); + } + } else { + fprintf(f, FSTAB_FMT, uuid, "/", "auto", "defaults", 1, 1); + } + free(uuid); }