[Midnightbsd-cvs] src [8289] trunk/sys/boot/i386/zfsboot/zfsboot.c: use the same zfs dataset naming format as loader

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Sep 17 18:08:21 EDT 2016


Revision: 8289
          http://svnweb.midnightbsd.org/src/?rev=8289
Author:   laffer1
Date:     2016-09-17 18:08:21 -0400 (Sat, 17 Sep 2016)
Log Message:
-----------
use the same zfs dataset naming format as loader

Modified Paths:
--------------
    trunk/sys/boot/i386/zfsboot/zfsboot.c

Modified: trunk/sys/boot/i386/zfsboot/zfsboot.c
===================================================================
--- trunk/sys/boot/i386/zfsboot/zfsboot.c	2016-09-17 22:07:57 UTC (rev 8288)
+++ trunk/sys/boot/i386/zfsboot/zfsboot.c	2016-09-17 22:08:21 UTC (rev 8289)
@@ -14,7 +14,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD: src/sys/boot/i386/zfsboot/zfsboot.c,v 1.2 2012/12/29 04:58:21 laffer1 Exp $");
+__MBSDID("$MidnightBSD$");
 
 #include <sys/param.h>
 #include <sys/errno.h>
@@ -553,7 +553,7 @@
 	if (parse())
 	    autoboot = 0;
 	if (!OPT_CHECK(RBX_QUIET))
-	    printf("%s: %s", PATH_CONFIG, cmddup);
+	    printf("%s: %s\n", PATH_CONFIG, cmddup);
 	/* Do not process this command twice */
 	*cmd = 0;
     }
@@ -577,13 +577,17 @@
 	if (!autoboot || !OPT_CHECK(RBX_QUIET)) {
 	    printf("\nMidnightBSD/x86 boot\n");
 	    if (zfs_rlookup(spa, zfsmount.rootobj, rootname) != 0)
-		printf("Default: %s:<0x%llx>:%s\n"
+		printf("Default: %s/<0x%llx>:%s\n"
 		       "boot: ",
 		       spa->spa_name, zfsmount.rootobj, kname);
+	    else if (rootname[0] != '\0')
+		printf("Default: %s/%s:%s\n"
+		       "boot: ",
+		       spa->spa_name, rootname, kname);
 	    else
-		printf("Default: %s:%s:%s\n"
+		printf("Default: %s:%s\n"
 		       "boot: ",
-		       spa->spa_name, rootname, kname);
+		       spa->spa_name, kname);
 	}
 	if (ioctrl & IO_SERIAL)
 	    sio_flush();
@@ -708,12 +712,46 @@
 }
 
 static int
+zfs_mount_ds(char *dsname)
+{
+    uint64_t newroot;
+    spa_t *newspa;
+    char *q;
+
+    q = strchr(dsname, '/');
+    if (q)
+	*q++ = '\0';
+    newspa = spa_find_by_name(dsname);
+    if (newspa == NULL) {
+	printf("\nCan't find ZFS pool %s\n", dsname);
+	return -1;
+    }
+
+    if (zfs_spa_init(newspa))
+	return -1;
+
+    newroot = 0;
+    if (q) {
+	if (zfs_lookup_dataset(newspa, q, &newroot)) {
+	    printf("\nCan't find dataset %s in ZFS pool %s\n",
+		    q, newspa->spa_name);
+	    return -1;
+	}
+    }
+    if (zfs_mount(newspa, newroot, &zfsmount)) {
+	printf("\nCan't mount ZFS dataset\n");
+	return -1;
+    }
+    spa = newspa;
+    return (0);
+}
+
+static int
 parse(void)
 {
     char *arg = cmd;
     char *ep, *p, *q;
     const char *cp;
-    //unsigned int drv;
     int c, i, j;
 
     while ((c = *arg++)) {
@@ -773,37 +811,20 @@
 	    }
 
 	    /*
+	     * If there is "zfs:" prefix simply ignore it.
+	     */
+	    if (strncmp(arg, "zfs:", 4) == 0)
+		arg += 4;
+
+	    /*
 	     * If there is a colon, switch pools.
 	     */
-	    q = (char *) strchr(arg, ':');
+	    q = strchr(arg, ':');
 	    if (q) {
-		spa_t *newspa;
-		uint64_t newroot;
-
-		*q++ = 0;
-		newspa = spa_find_by_name(arg);
-		if (newspa) {
-		    arg = q;
-		    spa = newspa;
-		    newroot = 0;
-		    q = (char *) strchr(arg, ':');
-		    if (q) {
-			*q++ = 0;
-			if (zfs_lookup_dataset(spa, arg, &newroot)) {
-			    printf("\nCan't find dataset %s in ZFS pool %s\n",
-			        arg, spa->spa_name);
-			    return -1;
-			}
-			arg = q;
-		    }
-		    if (zfs_mount(spa, newroot, &zfsmount)) {
-			printf("\nCan't mount ZFS dataset\n");
-			return -1;
-		    }
-		} else {
-		    printf("\nCan't find ZFS pool %s\n", arg);
+		*q++ = '\0';
+		if (zfs_mount_ds(arg) != 0)
 		    return -1;
-		}
+		arg = q;
 	    }
 	    if ((i = ep - arg)) {
 		if ((size_t)i >= sizeof(kname))



More information about the Midnightbsd-cvs mailing list