From nobody Sat Sep 6 17:19:46 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=adacore.com ARC-Seal: i=1; a=rsa-sha256; t=1756886393; cv=none; d=zohomail.com; s=zohoarc; b=cQOx7gILhCR1xgCBEsKwhMGwKZmNqiULvdJKAOsbg7DvYw/KFlJG4rPKb9dcF5OzQtbpvcSdw+8xYIMsrWtD4ZDsu7E9eBKCyX3nhKXl6eZ+wlmiUfVYoQZQIkd4vl63cgMdXjbw0gzvNT5STu+vmYIDZhnvqStb80d/ezEtPx0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756886393; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c7mag5avFW+do0t0a1WlckVOJ6fYCC2t3DfnVJEOqkM=; b=J5Oq6JwQcGKnws7HZvtNxg1MGQtOxGMhGDpc1EjNR41FBfLBen84F47p0oYxBLsfiOV7/KdOz5xWcOoYd+ToXUPLpN37Qa6JRJVXDG5sJcVWg/5DmR5+fPsGYasvVMb1ZlA4lhhy4diBCMf7sKkWawt5JFlBLQKea0Zi4K/rLew= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17568863933541003.500496756221; Wed, 3 Sep 2025 00:59:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utiNb-0006sC-6G; Wed, 03 Sep 2025 03:58:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1utiNI-0006gL-Jp for qemu-devel@nongnu.org; Wed, 03 Sep 2025 03:57:49 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1utiNG-0005N0-4O for qemu-devel@nongnu.org; Wed, 03 Sep 2025 03:57:48 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-45b8b8d45b3so28290915e9.1 for ; Wed, 03 Sep 2025 00:57:43 -0700 (PDT) Received: from chigot-Dell.home ([2a01:cb15:80db:7c00:8880:8b9d:ac82:8ac6]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-45b7e7d2393sm227923335e9.3.2025.09.03.00.57.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Sep 2025 00:57:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1756886262; x=1757491062; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=c7mag5avFW+do0t0a1WlckVOJ6fYCC2t3DfnVJEOqkM=; b=VVHNG/O0zGlzDuRj+nnexINmujIJJaJFuHakLr4V5xPe5phBv8YHOMLBBJHpwZZvkf 30wlVyRdjzx2YPql3UvvZeSaIEJx7GSGXwVgqhtKMMYw9uAZtP94yeJtI+7+ndz0h0z0 dHAw2HCJpFNmztoM5XMwIhRPT++C4A69UM0/qIfoceOho4NRTvaSHiaOGjJSTnTU09/R r/B4hNcCNA/f7Qk9FfUGFqnQJvVjEu0DTfp627O6TMaLrB94pY3quFfE3mQLoBBg9MIr 3f+981Clk1FTyryX9Zi5NKcu3kKv7wigg5rg8uoxdCChVGtPmygYOv8f064GT+f5vEf5 TXrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756886262; x=1757491062; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c7mag5avFW+do0t0a1WlckVOJ6fYCC2t3DfnVJEOqkM=; b=kiME7m4RuMfs46Qk+pDVBziCj/29oegzM5D8ipXBeYi4UfD/uT+ooJiHAA62+npBdL uEO+S/RR9KC+zbj0R0JcvFvgGXkTW9h2azt3xVX6BN91q4p1n7Oy/tm3Z05jjFhg5ps8 d3AfWtDuHv8LOsIrwljTdYCYD5QoaT/YtvBDSsJ642Cycy12LSap6CHW/gteT1CIb/UY /N8fh82Jbpy7q4QtyQQ+NBxwwm+oPaZFtKKqXHU98WzSUw9x3Z3crYkOYvpFJxfRLvCa CmWefymHmNTXVBqTqaBQJsPOmhc86pNeLXLdYy5SwFARi2NOl9V2Ql5P5lTUDFaCTEvt YYhQ== X-Gm-Message-State: AOJu0YzlMllXVvUpJfPP2fAdH0f3HDdW4CGoVbGQrZxUuPCrjmJg2bpR Vfo0z4GYKgHWuw6INtABPIeEGyVowHe87fdwka9TSG+XuxUwV5Nvi0zfOjpdzyAYaWZB58YSn+h n9EA= X-Gm-Gg: ASbGncvYN8SIByY88YHBtgPMzJqYbwKSpfuSbqlezQyeskC/zr1Oca+nm9HCeWy3oZt QIS6hEU+Q8OnurJCLVKp+QWih8lakPeGpbYNgblwMel/dbkbjFBjWiYK0M544C4TWKee4EBIv9J NmPaROLbSlOs62HCpZlkS1Q1FL4ZIUlpzqrN8w+pmLM28Ld6NPgPX52NXmLs1BiBwN3Nzkf03Ez BMZX938OCwSPby2FqApCaqfTjOUvIXcl5MCv3evJfPZh7m11u77fD5bGO6OikXuav2ytweqDmSa qbMk+ZbBDCtTyKz91lnX0cDEt3ciwGYac8lVINoo6IgfQYsvOV/IRDh4KsVq1xzFOyfIGRWPjqG 6oN3qs9SFljer2h01et5kprA0p3ooOVAo6mxNWC4NouS8QE7yEUOn X-Google-Smtp-Source: AGHT+IHymHFqVyEXL2NfEOtxTjsRdjNonDf9Ojrc+0nCM67ZpQJyVaxCKkBp6DBE6Ox0NAvr9Crg/w== X-Received: by 2002:a05:600c:4f8f:b0:456:f1e:205c with SMTP id 5b1f17b1804b1-45b85550704mr117013025e9.4.1756886262282; Wed, 03 Sep 2025 00:57:42 -0700 (PDT) From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org, =?UTF-8?q?Cl=C3=A9ment=20Chigot?= Subject: [PATCH 2/5] vvfat: move fat_type check prior to size setup Date: Wed, 3 Sep 2025 09:57:18 +0200 Message-Id: <20250903075721.77623-3-chigot@adacore.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250903075721.77623-1-chigot@adacore.com> References: <20250903075721.77623-1-chigot@adacore.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=chigot@adacore.com; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @adacore.com) X-ZM-MESSAGEID: 1756886395577124100 This allows to handle the default FAT size in a single place and make the following part taking care only about size parameters. It will be later moved away in a specific function. Setting a floppy disk of 1MB is no longer possible as it was a side effect of passing "fat-type=3D12". To be precise there were three cases: - fat-type undefined (aka default): a fat12 2MB disk - fat-type=3D16: a fat16 2Mb disk - fat-type=3D12: a fat12 1Mb disk Now, that fat-type undefined means fat-type=3D2, it's no longer possible to make that size distinction. It will be added back a bit later, through the size parameter. Signed-off-by: Cl=C3=A9ment Chigot --- block/vvfat.c | 48 +++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 0220dd828b..91e4ad3158 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1190,45 +1190,51 @@ static int vvfat_open(BlockDriverState *bs, QDict *= options, int flags, memcpy(s->volume_label, "QEMU VVFAT", 10); } =20 - if (floppy) { - /* 1.44MB or 2.88MB floppy. 2.88MB can be FAT12 (default) or FAT1= 6. */ - if (!s->fat_type) { + /* Verify FAT type */ + switch (s->fat_type) { + case 32: + warn_report("FAT32 has not been tested. You are welcome to do so!"= ); + break; + case 16: + case 12: + break; + case 0: + /* Set a default type */ + if (floppy) { s->fat_type =3D 12; + } else { + s->fat_type =3D 16; + } + break; + default: + error_setg(errp, "Valid FAT types are only 12, 16 and 32"); + ret =3D -EINVAL; + goto fail; + } + + + if (floppy) { + /* 2.88MB floppy */ + if (s->fat_type =3D=3D 12) { secs =3D 36; s->sectors_per_cluster =3D 2; } else { - secs =3D s->fat_type =3D=3D 12 ? 18 : 36; + secs =3D 36; s->sectors_per_cluster =3D 1; } cyls =3D 80; heads =3D 2; } else { - /* 32MB or 504MB disk*/ - if (!s->fat_type) { - s->fat_type =3D 16; - } /* Reserver space for MBR */ if (!qemu_opt_get_bool(opts, "no-mbr", false)) { s->offset_to_bootsector =3D 0x3f; } + /* 32MB or 504MB disk*/ cyls =3D s->fat_type =3D=3D 12 ? 64 : 1024; heads =3D 16; secs =3D 63; } =20 - switch (s->fat_type) { - case 32: - warn_report("FAT32 has not been tested. You are welcome to do so!"= ); - break; - case 16: - case 12: - break; - default: - error_setg(errp, "Valid FAT types are only 12, 16 and 32"); - ret =3D -EINVAL; - goto fail; - } - =20 s->bs =3D bs; =20 --=20 2.34.1