Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 25 Apr 2019 15:09:21 +0000 (UTC)
From:      Ian Lepore <ian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346675 - head/stand/common
Message-ID:  <201904251509.x3PF9LCE075118@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ian
Date: Thu Apr 25 15:09:21 2019
New Revision: 346675
URL: https://svnweb.freebsd.org/changeset/base/346675

Log:
  Restore the ability to open a raw disk or partition in loader(8).
  
  The disk_open() function searches for "the best partition" when slice and
  partition information is not provided as part of the device name.  As of
  r345477 the slice and partition fields of a disk_devdesc are initialized to
  D_SLICEWILD and D_PARTWILD; in the past they were initialized to -1, which
  was sometimes interpreted as meaning 'wildcard' and sometimes as 'open the
  raw partition' depending on the context.  So as an unintended side effect of
  r345477 it became basically impossible to ever open a disk or partition
  without doing the 'best partition' search.  One visible effect of that was
  the inability to open the raw disk to read the partition table correctly in
  zfs_probe_dev(), leading to failures to find the zfs pool unless it was on
  the first partition.
  
  Now instead of always initializing slice and partition to wildcards, the
  disk_parsedev() function initializes them based on the presence of a
  path/file name following the device.  If there is any path or filename
  following the ':' that ends the device name, then slice and partition are
  initialized to D_SLICEWILD and D_PARTWILD.  If there is nothing after the
  ':' then it is considered to be a request to open the raw device or
  partition itself (not a file stored within it), and the fields are
  initialized to D_SLICENONE and D_PARTNONE.
  
  With this change in place, all the tests in src/tools/boot are succesful
  again, including the recently-added cases of booting from a zfs pool on
  a partition other than slice 1 of the device.
  
  PR:		236981

Modified:
  head/stand/common/disk.c

Modified: head/stand/common/disk.c
==============================================================================
--- head/stand/common/disk.c	Thu Apr 25 14:41:29 2019	(r346674)
+++ head/stand/common/disk.c	Thu Apr 25 15:09:21 2019	(r346675)
@@ -392,8 +392,20 @@ disk_parsedev(struct disk_devdesc *dev, const char *de
 
 	np = devspec;
 	unit = -1;
-	slice = D_SLICEWILD;
-	partition = D_PARTWILD;
+	/*
+	 * If there is path/file info after the device info, then any missing
+	 * slice or partition info should be considered a request to search for
+	 * an appropriate partition.  Otherwise we want to open the raw device
+	 * itself and not try to fill in missing info by searching.
+	 */
+	if ((cp = strchr(np, ':')) != NULL && cp[1] != '\0') {
+		slice = D_SLICEWILD;
+		partition = D_PARTWILD;
+	} else {
+		slice = D_SLICENONE;
+		partition = D_PARTNONE;
+	}
+
 	if (*np != '\0' && *np != ':') {
 		unit = strtol(np, &cp, 10);
 		if (cp == np)



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904251509.x3PF9LCE075118>