On Tue, 12 Sep 2006 02:43:40 +0200
Zoran Ivanic <[EMAIL PROTECTED]> wrote:

> Nice, works ok for me with cdroms, but coredumps when trying to boot two 
> bootable dvds i have.
> 
> Floating point exception (core dumped)
> 
> gdb says something about intentionally dividing by zero..

Here's a revised patch-block_c
Does it improve the situation?

--- block.c.orig        Wed May  3 20:32:58 2006
+++ block.c     Tue Sep 12 07:31:30 2006
@@ -30,6 +30,7 @@
 #include <sys/ioctl.h>
 #include <sys/queue.h>
 #include <sys/disk.h>
+#include <sys/disklabel.h>
 #endif
 
 #ifdef CONFIG_COCOA
@@ -671,6 +672,7 @@
     int64_t size;
 #ifdef _BSD
     struct stat sb;
+    struct disklabel lab;
 #endif
 #ifdef __sun__
     struct dk_minfo minfo;
@@ -685,36 +687,10 @@
         bs->read_only = 1;
     }
 #ifdef _BSD
-    if (!fstat(fd, &sb) && (S_IFCHR & sb.st_mode)) {
-#ifdef DIOCGMEDIASIZE
-       if (ioctl(fd, DIOCGMEDIASIZE, (off_t *)&size))
-#endif
-#ifdef CONFIG_COCOA
-        size = LONG_LONG_MAX;
-#else
-        size = lseek(fd, 0LL, SEEK_END);
-#endif
-    } else
-#endif
-#ifdef __sun__
-    /*
-     * use the DKIOCGMEDIAINFO ioctl to read the size.
-     */
-    rv = ioctl ( fd, DKIOCGMEDIAINFO, &minfo );
-    if ( rv != -1 ) {
-        size = minfo.dki_lbsize * minfo.dki_capacity;
-    } else /* there are reports that lseek on some devices
-              fails, but irc discussion said that contingency
-              on contingency was overkill */
-#endif
-    {
-        size = lseek(fd, 0, SEEK_END);
-    }
-#ifdef _WIN32
-    /* On Windows hosts it can happen that we're unable to get file size
-       for CD-ROM raw device (it's inherent limitation of the CDFS driver). */
-    if (size == -1)
-        size = LONG_LONG_MAX;
+    if (0 == fstat(fd, &sb) && S_IFBLK == (S_IFBLK & sb.st_mode) && 1 != 
ioctl(fd, DIOCGDINFO, &lab))
+       size = (int64_t)lab.d_secsize * (int64_t)lab.d_secperunit;
+    else
+       size = lseek(fd, 0, SEEK_END);
 #endif
     bs->total_sectors = size / 512;
     s->fd = fd;

Reply via email to