[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 1/6] vvfat: Fix bug in writing to middle of file
From: |
Amjad Alsharafi |
Subject: |
[PATCH v3 1/6] vvfat: Fix bug in writing to middle of file |
Date: |
Sun, 26 May 2024 17:56:01 +0800 |
Before this commit, the behavior when calling `commit_one_file` for
example with `offset=0x2000` (second cluster), what will happen is that
we won't fetch the next cluster from the fat, and instead use the first
cluster for the read operation.
This is due to off-by-one error here, where `i=0x2000 !< offset=0x2000`,
thus not fetching the next cluster.
Signed-off-by: Amjad Alsharafi <amjadsharafi10@gmail.com>
---
block/vvfat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block/vvfat.c b/block/vvfat.c
index 9d050ba3ae..ab342f0743 100644
--- a/block/vvfat.c
+++ b/block/vvfat.c
@@ -2525,7 +2525,7 @@ commit_one_file(BDRVVVFATState* s, int dir_index,
uint32_t offset)
return -1;
}
- for (i = s->cluster_size; i < offset; i += s->cluster_size)
+ for (i = s->cluster_size; i <= offset; i += s->cluster_size)
c = modified_fat_get(s, c);
fd = qemu_open_old(mapping->path, O_RDWR | O_CREAT | O_BINARY, 0666);
--
2.45.0
- [PATCH v3 0/6] vvfat: Fix write bugs for large files and add iotests, Amjad Alsharafi, 2024/05/26
- [PATCH v3 1/6] vvfat: Fix bug in writing to middle of file,
Amjad Alsharafi <=
- [PATCH v3 2/6] vvfat: Fix usage of `info.file.offset`, Amjad Alsharafi, 2024/05/26
- [PATCH v3 3/6] vvfat: Fix reading files with non-continuous clusters, Amjad Alsharafi, 2024/05/26
- [PATCH v3 5/6] iotests: Filter out `vvfat` fmt from failing tests, Amjad Alsharafi, 2024/05/26
- [PATCH v3 4/6] iotests: Add `vvfat` tests, Amjad Alsharafi, 2024/05/26
- [PATCH v3 6/6] iotests: Add `create_file` test for `vvfat` driver, Amjad Alsharafi, 2024/05/26
- Re: [PATCH v3 0/6] vvfat: Fix write bugs for large files and add iotests, Kevin Wolf, 2024/05/31