[Prev][Next][Index][Thread]

Re: OSKit bug in partition checker



I redirected the CC to the oskit-users list.  I think this bug should
affect all extant oskit kernels when used on large disks with an extended
partition starting past 2GB.

Please let me know if this alternate patch works just as well for you.


Index: find_blkio.c
===================================================================
RCS file: /n/moab/x/flux/CVS/oskit/diskpart/find_blkio.c,v
retrieving revision 1.7
diff -u -b -p -r1.7 find_blkio.c
--- find_blkio.c	2001/02/03 06:15:06	1.7
+++ find_blkio.c	2002/03/30 19:39:24
@@ -24,9 +24,18 @@ blkio_read(void *arg, int start, char *b
 	oskit_size_t blksize;
 	oskit_error_t err;
 	oskit_size_t nbytes;
+	oskit_off_t ofs;
 
 	blksize = oskit_blkio_getblocksize(b);
-	err = oskit_blkio_read(b, buf, start * blksize, blksize, &nbytes);
+
+	/*
+	 * Though start is only 32 bits, start*blksize could overflow that.
+	 * So we need to cast to oskit_off_t (64 bits) first.
+	 * As per comment below, we shift to avoid needing -lgcc for __muldi3.
+	 */
+	ofs = (oskit_off_t)start << (ffs(blksize) - 1);
+
+	err = oskit_blkio_read(b, buf, ofs, blksize, &nbytes);
 	if (err)
 		return err;

> 
> This probably belongs on bug-oskit or something instead of
> here, but I just thought I'd point out a problem I found
> in the oskit St. Patrick's day release (and prior releases)
> dealing with the partition table reading.  It manifested
> itself when I began trying to use oskit-mach instead of
> gnumach.
> 
> It seems that type promotion from 32 bit (oskit_size_t) 
> to 64 bit (oskit_off_t) is not automatic and this bug
> manifests itself on my system because of the very large
> disk and extended partitions I'm using.
> 
> At any rate, the problem is that the offset for the read in
> diskpart/find_blkio.c overflows on my system unless I explicitly
> type-cast the variables to 64 bit offsets (oskit_off_t).
> 
> If allowed to overflow, we read the wrong portion of the
> disk to find the extended partition entry and the table
> gets very confused and can't read the extended partitions.
> 
> The following (one line) patch fixes the problem and I can
> boot the Hurd with oskit-mach and see all my partitions.
> 
> *** oskit-20020317/diskpart/find_blkio.c.orig   Sat Mar 30 09:24:43 2002
> --- oskit-20020317/diskpart/find_blkio.c        Sat Mar 30 09:25:00 2002
> ***************
> *** 37,43 ****
>         oskit_size_t nbytes;
>   
>         blksize = oskit_blkio_getblocksize(b);
> !       err = oskit_blkio_read(b, buf, start * blksize, blksize,
> &nbytes);
>         if (err)
>                 return err;
>   
> --- 37,43 ----
>         oskit_size_t nbytes;
>   
>         blksize = oskit_blkio_getblocksize(b);
> !       err = oskit_blkio_read(b, buf, (oskit_off_t)start *
> (oskit_off_t)blksize, blksize, &nbytes);
>         if (err)
>                 return err;
>   
> 
> 
> 
> Jonathan S. Arney
> Software Engineer
> jarney1@cox.net
> ------------------------------------------------------------------------
> Some people call me a nihilist.
> That would be true except I don't believe in nihilism.
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Bug-hurd mailing list
> Bug-hurd@gnu.org
> http://mail.gnu.org/mailman/listinfo/bug-hurd

Follow-Ups: