bug-grub
[Top][All Lists]
Advanced

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

Bug and patch for BSD partition detection


From: Heikki Vatiainen
Subject: Bug and patch for BSD partition detection
Date: Sat, 02 Dec 2000 20:15:25 +0200

[I'm not on the bug-grub list, so Cc:s are welcome]

I was experimenting with installing FreeBSD, NetBSD and OpenBSD to 
same "primary" FDISK partition. While doing this, I noticed that a 
change in grub between versions 0.5.95 and 0.5.96 broke the BSD 
slice (a, b, c, etc.) detection. Here is an example: first with 
0.5.95 and then with 0.5.96 (partition 1 contains Solaris 8).


    GRUB  version 0.5.95  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]

grub> geometry (hd0)
drive 0x80: C/H/S = 3737/255/63, The number of sectors = 60036480, /dev/rwd0
   Partition num: 1,  Filesystem type unknown, partition type 0x82
   Partition num: 2, [BSD sub-partitions immediately follow]
     BSD Partition num: 'a',  Filesystem type is ffs, partition type 0xa5
     BSD Partition num: 'b',  Filesystem type unknown, partition type 0xa5
     BSD Partition num: 'e',  Filesystem type is ffs, partition type 0xa5
     BSD Partition num: 'f',  Filesystem type is ffs, partition type 0xa5

grub> 



    GRUB  version 0.5.96  (640K lower / 3072K upper memory)

 [ Minimal BASH-like line editing is supported.  For the first word, TAB
   lists possible command completions.  Anywhere else TAB lists the possible
   completions of a device/filename. ]

grub> geometry (hd0)
drive 0x80: C/H/S = 3737/255/63, The number of sectors = 60036480, /dev/rwd0
   Partition num: 1,  Filesystem type unknown, partition type 0x82
   Partition num: 2, [BSD sub-partitions immediately follow]
     BSD Partition num: 'a',  Filesystem type is ffs, partition type 0xa5

grub> 


BSD partition 'a' contains OpenBSD, 'e' contains NetBSD and 'f' 
contains FreeBSD. 

The current CVS version was also not working, so I poked around 
the code a bit and located the problem to the end of 
stage2/disk_io.c:next_partition() in which an if statement was 
getting wrong result from IS_PC_SLICE_TYPE_BSD macro.

My proposed fix is attached below. It always clears the possible
file system type found from the bits above the 8 lowest bits and
leaves only the partition type (0xa6 for OpenBSD, 0xa5 for FreeBSD,
etc.) left. With this fix I can now boot any of the BSDs with the 
CVS version of grub.


Index: stage2/pc_slice.h
===================================================================
RCS file: /cvs/grub/stage2/pc_slice.h,v
retrieving revision 1.10
diff -u -r1.10 pc_slice.h
--- stage2/pc_slice.h   2000/09/10 16:45:15     1.10
+++ stage2/pc_slice.h   2000/12/02 17:35:09
@@ -147,7 +147,7 @@
    || (type) == (PC_SLICE_TYPE_OPENBSD | ((fs) << 8)) \
    || (type) == (PC_SLICE_TYPE_NETBSD | (fs) << 8))
 
-#define IS_PC_SLICE_TYPE_BSD(type)     IS_PC_SLICE_TYPE_BSD_WITH_FS(type,0)
+#define IS_PC_SLICE_TYPE_BSD(type)     IS_PC_SLICE_TYPE_BSD_WITH_FS(((type) & 
0xFF),0)
 
 /*
  *  *BSD-style disklabel & partition definitions.


Heikki
-- 
Heikki Vatiainen                  * address@hidden
Tampere University of Technology  * Tampere, Finland







reply via email to

[Prev in Thread] Current Thread [Next in Thread]