Skip to contentSkip to conversation

vvfat: Fix regressions introduced in 2.4

PATCH In review Kevin Wolf 4 participants 9 messages Apr 28, 2016 – Apr 29, 2016 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

v2 cover vvfat: Fix regressions introduced in 2.4

Commit d5941dd added a little new feature and broke a few things (including the whole write support) while doing so. Let's fix this now and do a bit more careful testing when touching the driver in the future.

v2:
- Explicit pointer cast. Not sure why my gcc didn't warn. [Max]
- Coding style. In vvfat. Will be hard to beat the pointlessness of that review comment. [Max]

Kevin Wolf (2):
vvfat: Fix volume name assertion
vvfat: Fix default volume label

 block/vvfat.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH v2 1/2 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.

---
 block/vvfat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
block/vvfat.c +6 -1
index 6b85314..ff3df35 100644
@@ -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;
     }
 
Signature · 1 line
1.8.3.1
#2 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] vvfat: Fix volume name assertion

Quoted 4 lines · Kevin Wolf

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.

So you couldn't use this for writing at all, and we broke this a year ago, and nobody complained til now? Shows how little vvfat gets used...

thanks
-- PMM

Reviewed-by on v2 1/2
#3 lore raw

Re: [Qemu-devel] [PATCH v2 1/2] vvfat: Fix volume name assertion

In reply to Kevin Wolf
Quoted 19 lines · Kevin Wolf

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.

---
 block/vvfat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
block/vvfat.c +0 -0
index 6b85314..ff3df35 100644

block/vvfat.c DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp · line 2291

Quoted 10 lines
block/vvfat.c +1 -1
@@ -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));

Typing all of "QEMU VVAT" a third time was clearly too much.

block/vvfat.c DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp · line 2294

Quoted 3 lines
block/vvfat.c +3 -0
+
+        /* The first directory entry on the filesystem is the volume name */
+        first_direntry = (direntry_t*) s->directory.pointer;

I'd ask to correct the spacing to (direntry_t *)s if the spacing wasn't similarly off all over this file.

block/vvfat.c DLOG(fprintf(stderr, "commit_direntries for %s, parent_mapping_index %d\n", mapp · line 2298

Quoted 4 lines
block/vvfat.c +2 -0
+        assert(!memcmp(first_direntry->name, s->volume_label, 11));
+
 	current_dir_index += factor;
     }

Might want to to assert is_volume_label(), too. But even if you want to, let's not delay the fix for that.

Reviewed-by on v2 1/2
#4 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH v2 1/2] vvfat: Fix volume name assertion

In reply to Kevin Wolf
Quoted 5 lines · Kevin Wolf

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.

Quoted 8 lines

This fixes the assertion to compare with the configured volume name instead of a literal string.

---
 block/vvfat.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

I just noticed that Wolfgang's original patch got rid of the default "QEMU VVFAT " volume label. It now defaults to all spaces but I'm not sure if this causes any problems...

author
#5 lore raw

PATCH v2 2/2 vvfat: Fix default volume label

In reply to Kevin Wolf

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.

---
 block/vvfat.c | 2 ++
 1 file changed, 2 insertions(+)
block/vvfat.c +2 -0
index ff3df35..183fc4f 100644
@@ -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) {
Signature · 1 line
1.8.3.1
Reviewed-by on v2 2/2
#6 lore raw

Re: [Qemu-devel] [PATCH v2 2/2] vvfat: Fix default volume label

Quoted 3 lines · Kevin Wolf

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.

Hrmph.

Quoted 14 lines

This fixes the implementation to apply the advertised default.

---
 block/vvfat.c | 2 ++
 1 file changed, 2 insertions(+)
block/vvfat.c +0 -0
index ff3df35..183fc4f 100644

block/vvfat.c static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, · line 1116

Quoted 8 lines
block/vvfat.c +2 -0
@@ -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) {
Reviewed-by on v2 2/2
#7 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH v2 2/2] vvfat: Fix default volume label

In reply to Kevin Wolf
Quoted 4 lines · Kevin Wolf

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.

Quoted 8 lines

This fixes the implementation to apply the advertised default.

---
 block/vvfat.c | 2 ++
 1 file changed, 2 insertions(+)

Nice, thanks for fixing this.

#8 lore raw
In reply to Kevin Wolf
Quoted 9 lines · Kevin Wolf

Commit d5941dd added a little new feature and broke a few things (including the whole write support) while doing so. Let's fix this now and do a bit more careful testing when touching the driver in the future.

v2:
- Explicit pointer cast. Not sure why my gcc didn't warn. [Max]
- Coding style. In vvfat. Will be hard to beat the pointlessness of that review comment. [Max]

Quoted 6 lines

Kevin Wolf (2):
vvfat: Fix volume name assertion
vvfat: Fix default volume label

 block/vvfat.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

I think we could apply this to master tomorrow; review for patch 1 would be nice.

thanks
-- PMM