Skip to contentSkip to conversation

floppy read of incomplete sectors

Qemu-devel Jani Monoses 1 participant 1 message Aug 5, 2004

lore
Share & tools
lore
#0 lore raw

The same issue of two weeks ago, causing some apps to fail because the last sector is not being read if the file serving as floppy image is not a multiple of 512 bytes.
The patch is against CVS, the new raw_block code.

Jani

Index: block.c
===================================================================
RCS file: /cvsroot/qemu/qemu/block.c,v
retrieving revision 1.12

block.c +1 -1
diff -u -p -5 -r1.12 block.c
@@ -534,11 +534,11 @@ static int raw_read(BlockDriverState *bs
     BDRVRawState *s = bs->opaque;
     int ret;
     
     lseek(s->fd, sector_num * 512, SEEK_SET);
     ret = read(s->fd, buf, nb_sectors * 512);
-    if (ret != nb_sectors * 512) 
+    if (ret == -1)	
         return -1;
     return 0;
 }
 
 static int raw_write(BlockDriverState *bs, int64_t sector_num,