From owner-svn-src-all@FreeBSD.ORG Wed Aug 15 10:11:29 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CD81C106564A; Wed, 15 Aug 2012 10:11:29 +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 B80B08FC0C; Wed, 15 Aug 2012 10:11:29 +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 q7FABTMf036754; Wed, 15 Aug 2012 10:11:29 GMT (envelope-from ae@svn.freebsd.org) Received: (from ae@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q7FABTLl036752; Wed, 15 Aug 2012 10:11:29 GMT (envelope-from ae@svn.freebsd.org) Message-Id: <201208151011.q7FABTLl036752@svn.freebsd.org> From: "Andrey V. Elsukov" Date: Wed, 15 Aug 2012 10:11:29 +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: r239293 - 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: Wed, 15 Aug 2012 10:11:29 -0000 Author: ae Date: Wed Aug 15 10:11:29 2012 New Revision: 239293 URL: http://svn.freebsd.org/changeset/base/239293 Log: Rework r239232 to unbreak ZFS detection on MBR slices. Modified: head/sys/boot/common/disk.c Modified: head/sys/boot/common/disk.c ============================================================================== --- head/sys/boot/common/disk.c Wed Aug 15 09:18:49 2012 (r239292) +++ head/sys/boot/common/disk.c Wed Aug 15 10:11:29 2012 (r239293) @@ -187,16 +187,14 @@ disk_open(struct disk_devdesc *dev, off_ dev->d_offset = part.start; if (dev->d_partition == 255) goto out; /* Nothing more to do */ - if (dev->d_partition == -1) { - /* - * If we are looking at a BSD slice, and the - * partition is < 0, assume the 'a' partition. - */ - if (part.type == PART_FREEBSD) - dev->d_partition = 0; - else - goto out; - } + /* + * If d_partition < 0 and we are looking at a BSD slice, + * then try to read BSD label, otherwise return the + * whole MBR slice. + */ + if (dev->d_partition == -1 && + part.type != PART_FREEBSD) + goto out; /* Try to read BSD label */ table = ptable_open(dev, part.end - part.start + 1, od->sectorsize, ptblread); @@ -205,6 +203,16 @@ disk_open(struct disk_devdesc *dev, off_ rc = ENXIO; goto out; } + /* + * If slice contains BSD label and d_partition < 0, then + * assume the 'a' partition. Otherwise just return the + * whole MBR slice, because it can contain ZFS. + */ + if (dev->d_partition < 0) { + if (ptable_gettype(table) != PTABLE_BSD) + goto out; + dev->d_partition = 0; + } rc = ptable_getpart(table, &part, dev->d_partition); if (rc != 0) goto out;