From nobody Sat Feb 7 08:44:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=reactos.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166542996346940.962525839498426; Mon, 10 Oct 2022 12:26:03 -0700 (PDT) Received: from localhost ([::1]:42020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohyPa-0004zS-6y for importer@patchew.org; Mon, 10 Oct 2022 15:26:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36872) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohx0D-0006Si-Hq; Mon, 10 Oct 2022 13:55:46 -0400 Received: from iserv.reactos.org ([2a01:4f8:1c17:5ae1::1]:43272) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohx0A-0003sj-78; Mon, 10 Oct 2022 13:55:45 -0400 Received: by iserv.reactos.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ohx02-00015P-9A; Mon, 10 Oct 2022 17:55:34 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=reactos.org ; s=25047; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7oValN6Lat5aa5YBbgXxYSJfdKDsubCuBjYcfTSaqRI=; b=t8cH2xYG1MZK/C/P04mnfTMBHy IWcqEkjea2+0BeOs4kYayK2eKtSJCOuM+udBk0vSza5FZD0RVCrStisL8F7K8iXfNRsNvvHCr6Hka hq8fRMeBwUI1woQupp3HnB+nVGiCpEZgLzgyaBoeWciHIJ9T/QbpXGAIsioWTNy8MaJc=; From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= Subject: [PATCH v2 1/2] vvfat: allow some writes to bootsector Date: Mon, 10 Oct 2022 19:55:10 +0200 Message-Id: <20221010175511.3414357-2-hpoussin@reactos.org> X-Mailer: git-send-email 2.36.2 In-Reply-To: <20221010175511.3414357-1-hpoussin@reactos.org> References: <20221010175511.3414357-1-hpoussin@reactos.org> 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=2a01:4f8:1c17:5ae1::1; envelope-from=hpoussin@reactos.org; helo=iserv.reactos.org 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, 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" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1665429965510100001 'reserved1' field in bootsector is used to mark volume dirty, or need to ve= rify. Allow writes to bootsector which only changes the 'reserved1' field. This fixes I/O errors on Windows guests. Resolves: https://bugs.launchpad.net/qemu/+bug/1889421 Signed-off-by: Herv=C3=A9 Poussineau --- block/vvfat.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/block/vvfat.c b/block/vvfat.c index d6dd919683d..ae53f0d7283 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2993,11 +2993,35 @@ DLOG(checkpoint()); =20 vvfat_close_current_file(s); =20 + if (sector_num =3D=3D s->offset_to_bootsector && nb_sectors =3D=3D 1) { + /* + * Write on bootsector. Allow only changing the reserved1 field, + * used to mark volume dirtiness + */ + unsigned char *bootsector =3D s->first_sectors + + s->offset_to_bootsector * 0x200; + /* + * LATER TODO: if FAT32, this is wrong (see init_directories(), + * which always creates a FAT16 bootsector) + */ + const int reserved1_offset =3D offsetof(bootsector_t, u.fat16.rese= rved1); + + for (i =3D 0; i < 0x200; i++) { + if (i !=3D reserved1_offset && bootsector[i] !=3D buf[i]) { + fprintf(stderr, "Tried to write to protected bootsector\n"= ); + return -1; + } + } + + /* Update bootsector with the only updatable byte, and return succ= ess */ + bootsector[reserved1_offset] =3D buf[reserved1_offset]; + return 0; + } + /* * Some sanity checks: * - do not allow writing to the boot sector */ - if (sector_num < s->offset_to_fat) return -1; =20 --=20 2.36.2 From nobody Sat Feb 7 08:44:04 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=reactos.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1665430453498542.8926702667248; Mon, 10 Oct 2022 12:34:13 -0700 (PDT) Received: from localhost ([::1]:48428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ohyXS-0005m8-BB for importer@patchew.org; Mon, 10 Oct 2022 15:34:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36870) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohx0D-0006Sg-HT; Mon, 10 Oct 2022 13:55:45 -0400 Received: from iserv.reactos.org ([2a01:4f8:1c17:5ae1::1]:43296) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ohx0A-0003tH-7V; Mon, 10 Oct 2022 13:55:45 -0400 Received: by iserv.reactos.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ohx06-00015P-AE; Mon, 10 Oct 2022 17:55:38 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=reactos.org ; s=25047; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=fwqztHUkQKRjjrrden7wbaSYG99/zQpEUNJ/XxS0Auc=; b=ZGItRIC2nvXSobgFRVBCCYzByF 4XGNc1Fi/2HAWvOLdHqgnDztuSTGshdWK6N7zVWLKl+1Bgd8tRfAQmnHv2S8WU0txR8GF1j/6GZmw ST+GEqEZtnkZcTTwlcjBsAuPr9Oq+YcagfFNYE/SfXALLO8DXs6xAwFDOnbs0Ks9qA6E=; From: =?UTF-8?q?Herv=C3=A9=20Poussineau?= To: kwolf@redhat.com, hreitz@redhat.com, qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/2] vvfat: allow spaces in file names Date: Mon, 10 Oct 2022 19:55:11 +0200 Message-Id: <20221010175511.3414357-3-hpoussin@reactos.org> X-Mailer: git-send-email 2.36.2 In-Reply-To: <20221010175511.3414357-1-hpoussin@reactos.org> References: <20221010175511.3414357-1-hpoussin@reactos.org> 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=2a01:4f8:1c17:5ae1::1; envelope-from=hpoussin@reactos.org; helo=iserv.reactos.org 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, 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" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1665430454120100001 In R/W mode, files with spaces were never created on host side. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1176 Fixes: c79e243ed67683d6d06692bd7040f7394da178b0 Signed-off-by: Herv=C3=A9 Poussineau Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Kevin Wolf --- block/vvfat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vvfat.c b/block/vvfat.c index ae53f0d7283..392eab5168b 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -499,7 +499,7 @@ static bool valid_filename(const unsigned char *name) (c >=3D 'A' && c <=3D 'Z') || (c >=3D 'a' && c <=3D 'z') || c > 127 || - strchr("$%'-_@~`!(){}^#&.+,;=3D[]", c) !=3D NULL)) + strchr(" $%'-_@~`!(){}^#&.+,;=3D[]", c) !=3D NULL)) { return false; } --=20 2.36.2