From owner-svn-src-stable@FreeBSD.ORG Sun Oct 28 15:37:48 2012 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 7D772FB1; Sun, 28 Oct 2012 15:37:48 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 64C248FC17; Sun, 28 Oct 2012 15:37:48 +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 q9SFbmPP039711; Sun, 28 Oct 2012 15:37:48 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q9SFbmkA039708; Sun, 28 Oct 2012 15:37:48 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201210281537.q9SFbmkA039708@svn.freebsd.org> From: Andriy Gapon Date: Sun, 28 Oct 2012 15:37:48 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r242225 - stable/8/sys/boot/i386/zfsboot X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 28 Oct 2012 15:37:48 -0000 Author: avg Date: Sun Oct 28 15:37:47 2012 New Revision: 242225 URL: http://svn.freebsd.org/changeset/base/242225 Log: MFC r241288: zfsboot: use the same zfs dataset naming format as loader Modified: stable/8/sys/boot/i386/zfsboot/zfsboot.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/boot/ (props changed) Modified: stable/8/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- stable/8/sys/boot/i386/zfsboot/zfsboot.c Sun Oct 28 15:37:32 2012 (r242224) +++ stable/8/sys/boot/i386/zfsboot/zfsboot.c Sun Oct 28 15:37:47 2012 (r242225) @@ -548,7 +548,7 @@ main(void) 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; } @@ -572,13 +572,17 @@ main(void) if (!autoboot || !OPT_CHECK(RBX_QUIET)) { printf("\nFreeBSD/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 - printf("Default: %s:%s:%s\n" + else if (rootname[0] != '\0') + printf("Default: %s/%s:%s\n" "boot: ", spa->spa_name, rootname, kname); + else + printf("Default: %s:%s\n" + "boot: ", + spa->spa_name, kname); } if (ioctrl & IO_SERIAL) sio_flush(); @@ -703,12 +707,46 @@ load(void) } 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++)) { @@ -768,37 +806,20 @@ parse(void) } /* + * 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))