Menu

#1377 Fix Detection of Block Device vs Image File

fixed_in_SVN
closed
hdimage (1)
1
2015-10-25
2015-07-13
No

Bug: When HD image file is stored on a distributed filesystem, if fails to load because st_rdev is non-zero and (incorrectly) perceived by bochs to be an special device file.

Fix: When loading an image file, consult st_mode rather than st_rdev to determine if the file is a block device.

Patch:

--- bochs-20150710/iodev/hdimage/hdimage.cc 2015-03-29 10:27:32.000000000 -0400
+++ bochs-fixed/iodev/hdimage/hdimage.cc    2015-07-13 12:43:34.041858670 -0400
@@ -49,10 +49,11 @@
 #endif
 #ifdef linux
 #include <linux/fs.h>
 #include <sys/ioctl.h>
 #include <sys/wait.h>
+#include <fcntl.h>
 #endif

 #define LOG_THIS theHDImageCtl->

 #ifndef BXIMAGE
@@ -221,11 +222,11 @@
     if (fstat(fd, &stat_buf)) {
       BX_PANIC(("fstat() returns error!"));
       return -1;
     }
 #ifdef linux
-    if (stat_buf.st_rdev) { // Is this a special device file (e.g. /dev/sde) ?
+    if (S_ISBLK(stat_buf.st_mode)) { // Is this a special device file (e.g. /dev/sde) ?
       ioctl(fd, BLKGETSIZE64, fsize); // yes it's!
     }
     else
 #endif

Discussion

  • Volker Ruppert

    Volker Ruppert - 2015-10-25

    Fixed in SVN now.

     
  • Volker Ruppert

    Volker Ruppert - 2015-10-25
    • status: open --> closed
    • assigned_to: Volker Ruppert
    • Group: pending --> fixed_in_SVN
     

Log in to post a comment.