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=1756886396; cv=none; d=zohomail.com; s=zohoarc; b=ddqqYsZbn+ADURbApayCSsYdTa9s14JMJir4Cb33AglZQvauDaXpeFNJ15mXdbFubguM2f+5tkE66Uduv6jMjDk06hzcuj4taBN3MCiBHCMJ2rBaOxiCbyPIxE7qnmx7AKa8H3/51of6RV5+6g4cVeOEEa8rmTH8CrKcFosKJ70= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1756886396; 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=2MvWn5d6XqQ+RCyxskwcO5xPTfuSIuv1nwogU1KNBQ8=; b=n43okRd0y4zYEgAeWjqlTCo817mqJJLEvDdOwjxXynVFY1WVXjRSqXaZy15mHCkFtY3rxdKNERecYjzRKBxSHe/BT6JcwF+JzpAUnppKrPFZrmcdPFUed6PMxej3qMt7pxjUg0qmt04gcDM7t9FkzNt9rzcfEY8K+95QBTEoq+M= 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 1756886396659723.7121303713113; Wed, 3 Sep 2025 00:59:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1utiNd-0006uK-9P; Wed, 03 Sep 2025 03:58:09 -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-0006gU-Rm for qemu-devel@nongnu.org; Wed, 03 Sep 2025 03:57:49 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1utiNG-0005NE-4V for qemu-devel@nongnu.org; Wed, 03 Sep 2025 03:57:48 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-45cb6d8f42cso780205e9.1 for ; Wed, 03 Sep 2025 00:57:45 -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.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Sep 2025 00:57:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1756886263; x=1757491063; 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=2MvWn5d6XqQ+RCyxskwcO5xPTfuSIuv1nwogU1KNBQ8=; b=GtGpTbhBma1nDwEoo2k83CnUOld89RjZv8DLxRLCB6EvXmlnYN0ZY8nmePvSJgAszN JDZTDEysrqaP0n8RJumb+3Ppr1nT1QNOjh8DeHEdrWLG4NSwrhCjQmpZ+oFdTXVYCfRd x3WGVDgZSM7up2BNRSXVd5hSB42VJs7XdQdoeydUgXVr3oONVYKoOLFgBR9W3lS94G/p 7TvxesNKf/L5GVWbLoO+G2K+ZwXY+5BfRddBx4PT/DtdBpsQ6pS3GDg49AMMFOaIKDp1 lTLp0N1jndC3ngso1neI1qNCBdigw0oPLxXKfHixoDGdRwsv5LRt4U9mnLeu1AEpmOZd H3uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756886263; x=1757491063; 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=2MvWn5d6XqQ+RCyxskwcO5xPTfuSIuv1nwogU1KNBQ8=; b=bHje9LB7Gy6Kpr/f2W3jZm20uu2LUQTLVINm3bD3MZLUD2wgwgGUykSFdjoJaqC1k5 HU1PKNy6XQzxXBCJ1SoRFnVMx1cVYJ48E12a1/a1YiyAJM0qSzFSEx/+z4H8MAsMc5SG IexxosaBcEYTZBvPHDzLxgW90KmjcTvaE+4ty7q5qva08LD+K0rewvhqqn6fKiG23V3p dqe6TAmjqzdpLq8Wx6cYCfTvsjx2cEGHZnyr0pwx9OSR/lLbjmGvpV2n+aQIKOVHlyr7 wpT8IVtFf3PhS4VE2S9gXz52GmFtwjNxWuqtspoMjeEne43N0eNvtLLomdlR230+Wmwi HI1A== X-Gm-Message-State: AOJu0YwEBDQJhYxRgtj0GpDfyHAMFYowUi0WpTuStWgaCRj5UuZmTLXR ypY4sZJw7AgFla9PkX3Z5jpOmhwnt9iES5+2+4kGTBFMrcEnlQP9S2PeQZ2QCl8dZCmKJwZZA1E bdRc= X-Gm-Gg: ASbGncvdMXPwDEdnl2QrgmBnly2n2q+MZsUlHUxlWjKda1RcjtfdWo3PSIuM/Fk3jFH l+d9F6QML2Otojp2uh5qpTvFfpM4EWE7sdNn8b4QUbqeAL5qLdxeZt4SFib0VJZ48UMqiXmPTbS huQVPsqD3ujvEQT5Gr7IcmdtC89tShPV6dQwQebr3NP+GFvNnuYkIc61baVd8dUasI4rWDM+Uo3 7PYk+4inT+J1z8KzOr3v0Ks8OBZbMbgwk4QSbl68LLlaZw6tHHSz6C3mICUZe383SSJ815KUp4p F/ZFw2wjUhvy2VIPOk+3FlmNzvV9sRc5AVVY6NTjZz7je40yZq8wpWrDReVEd613DFwgPJy6xea HvmmmooSnqi9r44viM2BcVbJRl+L/Gc6DL6dLTmBNtQ== X-Google-Smtp-Source: AGHT+IFBYg85jtegp+rgc85j74OZxoHz/h7YMsDcACMjB31tKBf9twDAaWdraEPqVlP+FccJHzysPg== X-Received: by 2002:a05:600c:5486:b0:45b:8d2a:cd09 with SMTP id 5b1f17b1804b1-45b9bd607a7mr31567385e9.13.1756886263393; Wed, 03 Sep 2025 00:57:43 -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 4/5] vvfat: move size parameters within driver structure Date: Wed, 3 Sep 2025 09:57:20 +0200 Message-Id: <20250903075721.77623-5-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::32b; envelope-from=chigot@adacore.com; helo=mail-wm1-x32b.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=ham 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: 1756886399024116600 At the same time, rename them to match bootsector fields. Signed-off-by: Cl=C3=A9ment Chigot --- block/vvfat.c | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 6b6d158a18..6526c585a2 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -310,7 +310,10 @@ typedef struct BDRVVVFATState { =20 uint32_t offset_to_bootsector; /* 0 for floppy, 0x3f for disk */ =20 + unsigned int cylinders; unsigned int cluster_size; + unsigned int number_of_heads; + unsigned int sectors_per_track; unsigned int sectors_per_cluster; unsigned int sectors_per_fat; uint32_t last_cluster_of_root_directory; @@ -364,7 +367,7 @@ static int sector2CHS(mbr_chs_t *chs, int spos, int cyl= s, int heads, int secs) return 0; } =20 -static void init_mbr(BDRVVVFATState *s, int cyls, int heads, int secs) +static void init_mbr(BDRVVVFATState *s) { /* TODO: if the files mbr.img and bootsect.img exist, use them */ mbr_t* real_mbr=3D(mbr_t*)s->first_sectors; @@ -380,9 +383,9 @@ static void init_mbr(BDRVVVFATState *s, int cyls, int h= eads, int secs) =20 /* LBA is used when partition is outside the CHS geometry */ lba =3D sector2CHS(&partition->start_CHS, s->offset_to_bootsector, - cyls, heads, secs); + s->cylinders, s->number_of_heads, s->sectors_per_tra= ck); lba |=3D sector2CHS(&partition->end_CHS, s->bs->total_sectors - 1, - cyls, heads, secs); + s->cylinders, s->number_of_heads, s->sectors_per_tra= ck); =20 /*LBA partitions are identified only by start/length_sector_long not b= y CHS*/ partition->start_sector_long =3D cpu_to_le32(s->offset_to_bootsector); @@ -894,8 +897,7 @@ static inline off_t cluster2sector(BDRVVVFATState* s, u= int32_t cluster_num) return s->offset_to_root_dir + s->sectors_per_cluster * cluster_num; } =20 -static int init_directories(BDRVVVFATState* s, - const char *dirname, int heads, int secs, +static int init_directories(BDRVVVFATState *s, const char *dirname, Error **errp) { bootsector_t* bootsector; @@ -1028,8 +1030,8 @@ static int init_directories(BDRVVVFATState* s, bootsector->media_type =3D (s->offset_to_bootsector > 0 ? 0xf8 : 0xf0); s->fat.pointer[0] =3D bootsector->media_type; bootsector->sectors_per_fat=3Dcpu_to_le16(s->sectors_per_fat); - bootsector->sectors_per_track =3D cpu_to_le16(secs); - bootsector->number_of_heads =3D cpu_to_le16(heads); + bootsector->sectors_per_track =3D cpu_to_le16(s->sectors_per_track); + bootsector->number_of_heads =3D cpu_to_le16(s->number_of_heads); bootsector->hidden_sectors =3D cpu_to_le32(s->offset_to_bootsector); bootsector->total_sectors=3Dcpu_to_le32(s->sector_count>0xffff?s->sect= or_count:0); =20 @@ -1150,7 +1152,6 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, Error **errp) { BDRVVVFATState *s =3D bs->opaque; - int cyls, heads, secs; bool floppy; const char *dirname, *label; QemuOpts *opts; @@ -1218,23 +1219,23 @@ static int vvfat_open(BlockDriverState *bs, QDict *= options, int flags, if (floppy) { /* 2.88MB floppy */ if (s->fat_type =3D=3D 12) { - secs =3D 36; + s->sectors_per_track =3D 36; s->sectors_per_cluster =3D 2; } else { - secs =3D 36; + s->sectors_per_track =3D 36; s->sectors_per_cluster =3D 1; } - cyls =3D 80; - heads =3D 2; + s->cylinder =3D 80; + s->number_of_heads =3D 2; } else { /* 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; + s->cylinders =3D s->fat_type =3D=3D 12 ? 64 : 1024; + s->number_of_heads =3D 16; + s->sectors_per_track =3D 63; } =20 =20 @@ -1251,10 +1252,13 @@ static int vvfat_open(BlockDriverState *bs, QDict *= options, int flags, s->downcase_short_names =3D 1; =20 DLOG(fprintf(stderr, "vvfat %s chs %d,%d,%d\n", - dirname, cyls, heads, secs)); + dirname, s->cylinders, s->number_of_heads, + s->sectors_per_track)); =20 - s->sector_count =3D cyls * heads * secs - s->offset_to_bootsector; - bs->total_sectors =3D cyls * heads * secs; + s->sector_count =3D s->cylinders * s->number_of_heads * + s->sectors_per_track - s->offset_to_bootsector; + bs->total_sectors =3D s->cylinders * s->number_of_heads * + s->sectors_per_track; =20 if (qemu_opt_get_bool(opts, "rw", false)) { if (!bdrv_is_read_only(bs)) { @@ -1275,7 +1279,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, } } =20 - if (init_directories(s, dirname, heads, secs, errp)) { + if (init_directories(s, dirname, errp)) { ret =3D -EIO; goto fail; } @@ -1296,7 +1300,7 @@ static int vvfat_open(BlockDriverState *bs, QDict *op= tions, int flags, } =20 if (s->offset_to_bootsector > 0) { - init_mbr(s, cyls, heads, secs); + init_mbr(s); } =20 qemu_co_mutex_init(&s->lock); --=20 2.34.1