* [PATCH v2 0/2] Fix some problems with vvfat in R/W mode
@ 2022-10-10 17:55 Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 1/2] vvfat: allow some writes to bootsector Hervé Poussineau
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Hervé Poussineau @ 2022-10-10 17:55 UTC (permalink / raw)
To: kwolf, hreitz, qemu-block; +Cc: qemu-devel, Hervé Poussineau
Hi,
When testing vvfat in read-write mode, I came across some blocking
problems when using Windows guests.
This patchset is not here to fix all problems of vvfat, but only the
main ones I encountered.
First patch allows setting/resetting the 'volume dirty' flag on
boosector, and the second one allows creating file names with spaces.
Hervé
Changes since v1:
- updated patch 1 with remarks (modify in-memory copy, add comment about
FAT32)
Hervé Poussineau (2):
vvfat: allow some writes to bootsector
vvfat: allow spaces in file names
block/vvfat.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
--
2.36.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] vvfat: allow some writes to bootsector
2022-10-10 17:55 [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Hervé Poussineau
@ 2022-10-10 17:55 ` Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 2/2] vvfat: allow spaces in file names Hervé Poussineau
2022-10-21 9:45 ` [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Hervé Poussineau @ 2022-10-10 17:55 UTC (permalink / raw)
To: kwolf, hreitz, qemu-block; +Cc: qemu-devel, Hervé Poussineau
'reserved1' field in bootsector is used to mark volume dirty, or need to verify.
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é Poussineau <hpoussin@reactos.org>
---
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());
vvfat_close_current_file(s);
+ if (sector_num == s->offset_to_bootsector && nb_sectors == 1) {
+ /*
+ * Write on bootsector. Allow only changing the reserved1 field,
+ * used to mark volume dirtiness
+ */
+ unsigned char *bootsector = 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 = offsetof(bootsector_t, u.fat16.reserved1);
+
+ for (i = 0; i < 0x200; i++) {
+ if (i != reserved1_offset && bootsector[i] != buf[i]) {
+ fprintf(stderr, "Tried to write to protected bootsector\n");
+ return -1;
+ }
+ }
+
+ /* Update bootsector with the only updatable byte, and return success */
+ bootsector[reserved1_offset] = 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;
--
2.36.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] vvfat: allow spaces in file names
2022-10-10 17:55 [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 1/2] vvfat: allow some writes to bootsector Hervé Poussineau
@ 2022-10-10 17:55 ` Hervé Poussineau
2022-10-21 9:45 ` [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Hervé Poussineau @ 2022-10-10 17:55 UTC (permalink / raw)
To: kwolf, hreitz, qemu-block
Cc: qemu-devel, Hervé Poussineau, Philippe Mathieu-Daudé
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é Poussineau <hpoussin@reactos.org>
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
---
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 >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
c > 127 ||
- strchr("$%'-_@~`!(){}^#&.+,;=[]", c) != NULL))
+ strchr(" $%'-_@~`!(){}^#&.+,;=[]", c) != NULL))
{
return false;
}
--
2.36.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] Fix some problems with vvfat in R/W mode
2022-10-10 17:55 [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 1/2] vvfat: allow some writes to bootsector Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 2/2] vvfat: allow spaces in file names Hervé Poussineau
@ 2022-10-21 9:45 ` Kevin Wolf
2 siblings, 0 replies; 4+ messages in thread
From: Kevin Wolf @ 2022-10-21 9:45 UTC (permalink / raw)
To: Hervé Poussineau; +Cc: hreitz, qemu-block, qemu-devel
Am 10.10.2022 um 19:55 hat Hervé Poussineau geschrieben:
> Hi,
>
> When testing vvfat in read-write mode, I came across some blocking
> problems when using Windows guests.
> This patchset is not here to fix all problems of vvfat, but only the
> main ones I encountered.
>
> First patch allows setting/resetting the 'volume dirty' flag on
> boosector, and the second one allows creating file names with spaces.
>
> Hervé
>
> Changes since v1:
> - updated patch 1 with remarks (modify in-memory copy, add comment about
> FAT32)
Thanks, applied to the block branch.
Kevin
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-21 10:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-10 17:55 [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 1/2] vvfat: allow some writes to bootsector Hervé Poussineau
2022-10-10 17:55 ` [PATCH v2 2/2] vvfat: allow spaces in file names Hervé Poussineau
2022-10-21 9:45 ` [PATCH v2 0/2] Fix some problems with vvfat in R/W mode Kevin Wolf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).