On Thu, Apr 13, 2023 at 04:03:40PM +0200, Laszlo Ersek wrote:
Note that this patch is untested. In "make check",
"tests/test-floppy.sh"
passes. However, that test does not seem to pass the "size=..." option to
the plugin, and the code being modified in create_virtual_floppy() is
related to "size=..." -- at least it originates from commit c6d6113fa1f3
("floppy: support FAT FSes with unused space.", 2021-06-16).
Yes, we should really have insisted on a test here. Oh well ...
[...]
if (size > 0) {
uint64_t data_size = size - (2080 * SECTOR_SIZE);
- data_size = data_size - 2 * DIV_ROUND_UP ((data_size / CLUSTER_SIZE + 2) * 4,
- CLUSTER_SIZE) * CLUSTER_SIZE;
+ uint64_t fat_clusters = DIV_ROUND_UP ((data_size / CLUSTER_SIZE + 2) * 4,
+ CLUSTER_SIZE);
+ data_size -= 2 * fat_clusters * CLUSTER_SIZE;
The change itself eyeballs fine. I'll add a test later on.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
nbdkit - Flexible, fast NBD server with plugins
https://gitlab.com/nbdkit/nbdkit