Hardware watchdog
[qemu] / block-vvfat.c
index a2d37b9..7905931 100644 (file)
@@ -509,9 +509,12 @@ static inline uint8_t fat_chksum(const direntry_t* entry)
     uint8_t chksum=0;
     int i;
 
-    for(i=0;i<11;i++)
-       chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0))
-           +(unsigned char)entry->name[i];
+    for(i=0;i<11;i++) {
+        unsigned char c;
+
+        c = (i <= 8) ? entry->name[i] : entry->extension[i-8];
+        chksum=(((chksum&0xfe)>>1)|((chksum&0x01)?0x80:0)) + c;
+    }
 
     return chksum;
 }
@@ -1778,7 +1781,7 @@ DLOG(fprintf(stderr, "read cluster %d (sector %d)\n", (int)cluster_num, (int)clu
        }
 
        for (i = 0; i < 0x10 * s->sectors_per_cluster; i++) {
-           int cluster_count;
+           int cluster_count = 0;
 
 DLOG(fprintf(stderr, "check direntry %d: \n", i); print_direntry(direntries + i));
            if (is_volume_label(direntries + i) || is_dot(direntries + i) ||
@@ -2805,17 +2808,14 @@ static void vvfat_close(BlockDriverState *bs)
 }
 
 BlockDriver bdrv_vvfat = {
-    "vvfat",
-    sizeof(BDRVVVFATState),
-    NULL, /* no probe for protocols */
-    vvfat_open,
-    vvfat_read,
-    vvfat_write,
-    vvfat_close,
-    NULL, /* ??? Not sure if we can do any meaningful flushing.  */
-    NULL,
-    vvfat_is_allocated,
-    .protocol_name = "fat",
+    .format_name       = "vvfat",
+    .instance_size     = sizeof(BDRVVVFATState),
+    .bdrv_open         = vvfat_open,
+    .bdrv_read         = vvfat_read,
+    .bdrv_write                = vvfat_write,
+    .bdrv_close                = vvfat_close,
+    .bdrv_is_allocated = vvfat_is_allocated,
+    .protocol_name     = "fat",
 };
 
 #ifdef DEBUG