From owner-svn-src-all@FreeBSD.ORG Fri Sep 28 10:49:42 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 809E41065673; Fri, 28 Sep 2012 10:49:42 +0000 (UTC) (envelope-from ae@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6B2948FC08; Fri, 28 Sep 2012 10:49:42 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q8SAngRc023377; Fri, 28 Sep 2012 10:49:42 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q8SAngC2023375; Fri, 28 Sep 2012 10:49:42 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201209281049.q8SAngC2023375@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Fri, 28 Sep 2012 10:49:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r241023 - head/sys/boot/common X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 28 Sep 2012 10:49:42 -0000 Author: ae Date: Fri Sep 28 10:49:41 2012 New Revision: 241023 URL: http://svn.freebsd.org/changeset/base/241023 Log: Make the loader a bit smarter, when it tries to open disk and the slice number is not exactly specified. When the disk has MBR, also try to read BSD label after ptable_getpart() call. When the disk has GPT, also set d_partition to 255. Mostly, this is how it worked before. Modified: head/sys/boot/common/disk.c Modified: head/sys/boot/common/disk.c ============================================================================== --- head/sys/boot/common/disk.c Fri Sep 28 08:22:51 2012 (r241022) +++ head/sys/boot/common/disk.c Fri Sep 28 10:49:41 2012 (r241023) @@ -179,12 +179,21 @@ disk_open(struct disk_devdesc *dev, off_ rc = ptable_getpart(od->table, &part, dev->d_partition); if (rc == 0) dev->d_offset = part.start; - } else if (dev->d_slice > 0) { + } else if (dev->d_slice >= 0) { /* Try to get information about partition */ - rc = ptable_getpart(od->table, &part, dev->d_slice); + if (dev->d_slice == 0) + rc = ptable_getbestpart(od->table, &part); + else + rc = ptable_getpart(od->table, &part, dev->d_slice); if (rc != 0) /* Partition doesn't exist */ goto out; dev->d_offset = part.start; + if (dev->d_slice == 0) { + /* Save the slice number of best partition to dev */ + dev->d_slice = part.index; + if (ptable_gettype(od->table) == PTABLE_GPT) + dev->d_partition = 255; + } if (dev->d_partition == 255) goto out; /* Nothing more to do */ /* @@ -217,13 +226,6 @@ disk_open(struct disk_devdesc *dev, off_ if (rc != 0) goto out; dev->d_offset += part.start; - } else if (dev->d_slice == 0) { - rc = ptable_getbestpart(od->table, &part); - if (rc != 0) - goto out; - /* Save the slice number of best partition to dev */ - dev->d_slice = part.index; - dev->d_offset = part.start; } out: if (table != NULL)