[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 04/58] vvfat: allow some writes to bootsector
From: |
Kevin Wolf |
Subject: |
[PULL 04/58] vvfat: allow some writes to bootsector |
Date: |
Thu, 27 Oct 2022 20:30:52 +0200 |
From: Hervé Poussineau <hpoussin@reactos.org>
'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>
Message-Id: <20221010175511.3414357-2-hpoussin@reactos.org>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/vvfat.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index f9bf8406d3..e76b42dbaf 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.37.3
- [PULL 00/58] Block layer patches, Kevin Wolf, 2022/10/27
- [PULL 02/58] block: Ignore close() failure in get_tmp_filename(), Kevin Wolf, 2022/10/27
- [PULL 03/58] block: Refactor get_tmp_filename(), Kevin Wolf, 2022/10/27
- [PULL 01/58] MAINTAINERS: Fold "Block QAPI, monitor, ..." into "Block layer core", Kevin Wolf, 2022/10/27
- [PULL 07/58] vhost-user-blk: fix the resize crash, Kevin Wolf, 2022/10/27
- [PULL 05/58] vvfat: allow spaces in file names, Kevin Wolf, 2022/10/27
- [PULL 04/58] vvfat: allow some writes to bootsector,
Kevin Wolf <=
- [PULL 10/58] block/blklogwrites: don't care to remove bs->file child on failure, Kevin Wolf, 2022/10/27
- [PULL 12/58] tests-bdrv-drain: bdrv_replace_test driver: declare supports_backing, Kevin Wolf, 2022/10/27
- [PULL 14/58] block: document connection between child roles and bs->backing/bs->file, Kevin Wolf, 2022/10/27
- [PULL 08/58] block: BlockDriver: add .filtered_child_is_backing field, Kevin Wolf, 2022/10/27
- [PULL 11/58] test-bdrv-graph-mod: update test_parallel_perm_update test case, Kevin Wolf, 2022/10/27
- [PULL 15/58] block/snapshot: stress that we fallback to primary child, Kevin Wolf, 2022/10/27
- [PULL 06/58] block/io_uring: revert "Use io_uring_register_ring_fd() to skip fd operations", Kevin Wolf, 2022/10/27
- [PULL 17/58] Revert "block: Let replace_child_tran keep indirect pointer", Kevin Wolf, 2022/10/27
- [PULL 18/58] Revert "block: Restructure remove_file_or_backing_child()", Kevin Wolf, 2022/10/27
- [PULL 19/58] Revert "block: Pass BdrvChild ** to replace_child_noperm", Kevin Wolf, 2022/10/27