From ebb72c9f066e5f85259e1541a6d3fb5bfd6e73ff Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 27 Apr 2016 14:11:38 +0200 Subject: vvfat: Fix volume name assertion Commit d5941dd made the volume name configurable, but it didn't consider that the rw code compares the volume name string to assert that the first directory entry is the volume name. This made vvfat crash in rw mode. This fixes the assertion to compare with the configured volume name instead of a literal string. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi --- block/vvfat.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/vvfat.c b/block/vvfat.c index 6b853146f0..ff3df35eb0 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2283,12 +2283,17 @@ DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp factor * (old_cluster_count - new_cluster_count)); for (c = first_cluster; !fat_eof(s, c); c = modified_fat_get(s, c)) { + direntry_t *first_direntry; void* direntry = array_get(&(s->directory), current_dir_index); int ret = vvfat_read(s->bs, cluster2sector(s, c), direntry, s->sectors_per_cluster); if (ret) return ret; - assert(!strncmp(s->directory.pointer, "QEMU", 4)); + + /* The first directory entry on the filesystem is the volume name */ + first_direntry = (direntry_t*) s->directory.pointer; + assert(!memcmp(first_direntry->name, s->volume_label, 11)); + current_dir_index += factor; } -- cgit v1.2.1 From d208c50d9dbf98c0eca337723cd6497653ceb743 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 27 Apr 2016 14:18:16 +0200 Subject: vvfat: Fix default volume label Commit d5941dd documented that it leaves the default volume name as it was ("QEMU VVFAT"), but it doesn't actually implement this. You get an empty name (eleven space characters) instead. This fixes the implementation to apply the advertised default. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Markus Armbruster Reviewed-by: Stefan Hajnoczi --- block/vvfat.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/block/vvfat.c b/block/vvfat.c index ff3df35eb0..183fc4f049 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1109,6 +1109,8 @@ static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, goto fail; } memcpy(s->volume_label, label, label_length); + } else { + memcpy(s->volume_label, "QEMU VVFAT", 10); } if (floppy) { -- cgit v1.2.1