From nobody@FreeBSD.org  Fri Dec 10 06:34:25 2010
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id B3668106566B
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 10 Dec 2010 06:34:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (unknown [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 88F1A8FC16
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 10 Dec 2010 06:34:25 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id oBA6YPLC040745
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 10 Dec 2010 06:34:25 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id oBA6YPPL040744;
	Fri, 10 Dec 2010 06:34:25 GMT
	(envelope-from nobody)
Message-Id: <201012100634.oBA6YPPL040744@red.freebsd.org>
Date: Fri, 10 Dec 2010 06:34:25 GMT
From: Rick Richard <rick@lgarchitecture.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: [maintainer update] sysutils/grub2-1.98
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         152978
>Category:       ports
>Synopsis:       [maintainer update] sysutils/grub2-1.98
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pgollucci
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          maintainer-update
>Submitter-Id:   current-users
>Arrival-Date:   Fri Dec 10 06:40:08 UTC 2010
>Closed-Date:    Sun Dec 12 01:11:29 UTC 2010
>Last-Modified:  Sun Dec 12 01:20:09 UTC 2010
>Originator:     Rick Richard
>Release:        FreeBSD 8.1
>Organization:
>Environment:
>Description:
Follow-up on PR152389  to allow grub to recognize bsdlabel disklabels.

I confirmed the bug and tested the patch.  The original submission was for grub1 and grub2, here's the grub2 part.

>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ruN grub2.orig/Makefile grub2/Makefile
--- grub2.orig/Makefile	2010-10-12 08:48:46.000000000 -0700
+++ grub2/Makefile	2010-12-09 21:56:58.823684162 -0800
@@ -7,6 +7,7 @@
 
 PORTNAME=	grub2
 PORTVERSION=	1.98
+PORTREVISION=	1
 CATEGORIES=	sysutils
 MASTER_SITES=	ftp://alpha.gnu.org/gnu/grub/
 DISTNAME=	grub-${PORTVERSION}
diff -ruN grub2.orig/files/patch-bsd-partmap grub2/files/patch-bsd-partmap
--- grub2.orig/files/patch-bsd-partmap	1969-12-31 16:00:00.000000000 -0800
+++ grub2/files/patch-bsd-partmap	2010-12-09 21:56:58.823684162 -0800
@@ -0,0 +1,47 @@
+--- include/grub/msdos_partition.h	2010-03-06 20:51:37.000000000 +0000
++++ include/grub/msdos_partition.h	2010-11-17 18:22:29.000000000 +0000
+@@ -57,6 +57,7 @@
+ #define GRUB_PC_PARTITION_BSD_LABEL_SECTOR	1
+ #define GRUB_PC_PARTITION_BSD_LABEL_MAGIC	0x82564557
+ #define GRUB_PC_PARTITION_BSD_MAX_ENTRIES	8
++#define GRUB_PC_PARTITION_BSD_RAW_PART		2
+ 
+ /* BSD partition types.  */
+ #define GRUB_PC_PARTITION_BSD_TYPE_UNUSED	0
+--- partmap/msdos.c	2010-03-06 20:51:37.000000000 +0000
++++ partmap/msdos.c	2010-11-17 18:26:26.000000000 +0000
+@@ -176,6 +176,8 @@
+ 	      /* Check if this is a BSD partition.  */
+ 	      if (grub_msdos_partition_is_bsd (e->type))
+ 		{
++		  grub_uint32_t slice_offset = 0, raw_offset = 0;
++
+ 		  /* Check if the BSD label is within the DOS partition.  */
+ 		  if (p.len <= GRUB_PC_PARTITION_BSD_LABEL_SECTOR)
+ 		    {
+@@ -200,6 +202,15 @@
+ 				    label.magic, p.index);
+ 		      continue;
+ 		    }
++
++		  /* Compensate for relative addressing in FreeBSD. */
++		  if (e->type == GRUB_PC_PARTITION_TYPE_FREEBSD
++		      && GRUB_PC_PARTITION_BSD_RAW_PART < grub_cpu_to_le16 (label.num_partitions))
++		    {
++		      slice_offset = p.start;
++		      raw_offset = grub_le_to_cpu32 (label.entries[GRUB_PC_PARTITION_BSD_RAW_PART].offset);
++		    }
++
+ 		  for (pcdata.bsd_part = 0;
+ 		       pcdata.bsd_part < grub_cpu_to_le16 (label.num_partitions);
+ 		       pcdata.bsd_part++)
+@@ -207,7 +218,9 @@
+ 		      struct grub_msdos_partition_bsd_entry *be
+ 			= label.entries + pcdata.bsd_part;
+ 
++		      if (grub_le_to_cpu32 (be->offset) < raw_offset)
++			  continue;
+-		      p.start = grub_le_to_cpu32 (be->offset);
++		      p.start = grub_le_to_cpu32 (be->offset) - raw_offset + slice_offset;
+ 		      p.len = grub_le_to_cpu32 (be->size);
+ 		      pcdata.bsd_type = be->fs_type;


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->pgollucci 
Responsible-Changed-By: pgollucci 
Responsible-Changed-When: Sat Dec 11 00:05:53 UTC 2010 
Responsible-Changed-Why:  
I will take it. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152978 
State-Changed-From-To: open->closed 
State-Changed-By: pgollucci 
State-Changed-When: Sun Dec 12 01:11:28 UTC 2010 
State-Changed-Why:  
Committed, Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=152978 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/152978: commit references a PR
Date: Sun, 12 Dec 2010 01:11:29 +0000 (UTC)

 pgollucci    2010-12-12 01:11:24 UTC
 
   FreeBSD ports repository
 
   Modified files:
     sysutils/grub2       Makefile 
   Added files:
     sysutils/grub2/files patch-bsd-partmap 
   Log:
   - Allow grub to recognize bsdlabel disklabels.
   - Bump PORTREVISION
   
   PR:             ports/152978
   Submitted by:   Rick Richard <rick@lgarchitecture.com> (maintainer)
   
   Revision  Changes    Path
   1.5       +1 -0      ports/sysutils/grub2/Makefile
   1.1       +47 -0     ports/sysutils/grub2/files/patch-bsd-partmap (new)
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
>Unformatted:
