From owner-svn-src-stable@freebsd.org Wed Feb 10 17:49:24 2016 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F2B0AA322D; Wed, 10 Feb 2016 17:49:24 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18DBC1C07; Wed, 10 Feb 2016 17:49:24 +0000 (UTC) (envelope-from allanjude@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u1AHnN8b030558; Wed, 10 Feb 2016 17:49:23 GMT (envelope-from allanjude@FreeBSD.org) Received: (from allanjude@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u1AHnM19030552; Wed, 10 Feb 2016 17:49:22 GMT (envelope-from allanjude@FreeBSD.org) Message-Id: <201602101749.u1AHnM19030552@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: allanjude set sender to allanjude@FreeBSD.org using -f From: Allan Jude Date: Wed, 10 Feb 2016 17:49:22 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r295475 - in stable/10/sys/boot: efi/loader i386/loader userboot/userboot zfs X-SVN-Group: stable-10 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.20 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: Wed, 10 Feb 2016 17:49:24 -0000 Author: allanjude Date: Wed Feb 10 17:49:22 2016 New Revision: 295475 URL: https://svnweb.freebsd.org/changeset/base/295475 Log: Catch the EFI loader up to the latest ZFS Boot Environment Menu features MFC: r294072 Move init_zfs_bootenv to sys/boot/zfs/zfs.c instead of having a copy in each loader MFC: r294073 Connect the ZFS boot environment menu to the UEFI loader MFC: r295357 Do not set vfs.root.mountfrom unnecessarily when initializing ZFS BE menu Approved by: re (marius) Relnotes: yes Sponsored by: ScaleEngine Inc. Modified: stable/10/sys/boot/efi/loader/main.c stable/10/sys/boot/i386/loader/main.c stable/10/sys/boot/userboot/userboot/main.c stable/10/sys/boot/zfs/libzfs.h stable/10/sys/boot/zfs/zfs.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/efi/loader/main.c ============================================================================== --- stable/10/sys/boot/efi/loader/main.c Wed Feb 10 16:49:20 2016 (r295474) +++ stable/10/sys/boot/efi/loader/main.c Wed Feb 10 17:49:22 2016 (r295475) @@ -198,6 +198,7 @@ main(int argc, CHAR16 *argv[]) efi_setcurrdev, env_nounset); env_setenv("loaddev", EV_VOLATILE, efi_fmtdev(&currdev), env_noset, env_nounset); + init_zfs_bootenv(zfs_fmtdev(&currdev)); break; } #endif @@ -504,6 +505,38 @@ command_lszfs(int argc, char *argv[]) } return (CMD_OK); } + +COMMAND_SET(reloadbe, "reloadbe", "refresh the list of ZFS Boot Environments", + command_reloadbe); + +static int +command_reloadbe(int argc, char *argv[]) +{ + int err; + char *root; + + if (argc > 2) { + command_errmsg = "wrong number of arguments"; + return (CMD_ERROR); + } + + if (argc == 2) { + err = zfs_bootenv(argv[1]); + } else { + root = getenv("zfs_be_root"); + if (root == NULL) { + return (CMD_OK); + } + err = zfs_bootenv(root); + } + + if (err != 0) { + command_errmsg = strerror(err); + return (CMD_ERROR); + } + + return (CMD_OK); +} #endif #ifdef EFI_ZFS_BOOT Modified: stable/10/sys/boot/i386/loader/main.c ============================================================================== --- stable/10/sys/boot/i386/loader/main.c Wed Feb 10 16:49:20 2016 (r295474) +++ stable/10/sys/boot/i386/loader/main.c Wed Feb 10 17:49:22 2016 (r295475) @@ -69,7 +69,6 @@ static int isa_inb(int port); static void isa_outb(int port, int value); void exit(int code); #ifdef LOADER_ZFS_SUPPORT -static void init_zfs_bootenv(char *currdev); static void i386_zfs_probe(void); #endif @@ -303,34 +302,6 @@ extract_currdev(void) env_nounset); } -#ifdef LOADER_ZFS_SUPPORT -static void -init_zfs_bootenv(char *currdev) -{ - char *beroot; - - if (strlen(currdev) == 0) - return; - if(strncmp(currdev, "zfs:", 4) != 0) - return; - /* Remove the trailing : */ - currdev[strlen(currdev) - 1] = '\0'; - setenv("zfs_be_active", currdev, 1); - setenv("zfs_be_currpage", "1", 1); - /* Do not overwrite if already set */ - setenv("vfs.root.mountfrom", currdev, 0); - /* Forward past zfs: */ - currdev = strchr(currdev, ':'); - currdev++; - /* Remove the last element (current bootenv) */ - beroot = strrchr(currdev, '/'); - if (beroot != NULL) - beroot[0] = '\0'; - beroot = currdev; - setenv("zfs_be_root", beroot, 1); -} -#endif - COMMAND_SET(reboot, "reboot", "reboot the system", command_reboot); static int Modified: stable/10/sys/boot/userboot/userboot/main.c ============================================================================== --- stable/10/sys/boot/userboot/userboot/main.c Wed Feb 10 16:49:20 2016 (r295474) +++ stable/10/sys/boot/userboot/userboot/main.c Wed Feb 10 17:49:22 2016 (r295475) @@ -41,7 +41,6 @@ __FBSDID("$FreeBSD$"); static void userboot_zfs_probe(void); static int userboot_zfs_found; -static void init_zfs_bootenv(char *currdev); #endif #define USERBOOT_VERSION USERBOOT_VERSION_3 @@ -200,32 +199,6 @@ extract_currdev(void) #if defined(USERBOOT_ZFS_SUPPORT) static void -init_zfs_bootenv(char *currdev) -{ - char *beroot; - - if (strlen(currdev) == 0) - return; - if(strncmp(currdev, "zfs:", 4) != 0) - return; - /* Remove the trailing : */ - currdev[strlen(currdev) - 1] = '\0'; - setenv("zfs_be_active", currdev, 1); - setenv("zfs_be_currpage", "1", 1); - /* Do not overwrite if already set */ - setenv("vfs.root.mountfrom", currdev, 0); - /* Forward past zfs: */ - currdev = strchr(currdev, ':'); - currdev++; - /* Remove the last element (current bootenv) */ - beroot = strrchr(currdev, '/'); - if (beroot != NULL) - beroot[0] = '\0'; - beroot = currdev; - setenv("zfs_be_root", beroot, 1); -} - -static void userboot_zfs_probe(void) { char devname[32]; Modified: stable/10/sys/boot/zfs/libzfs.h ============================================================================== --- stable/10/sys/boot/zfs/libzfs.h Wed Feb 10 16:49:20 2016 (r295474) +++ stable/10/sys/boot/zfs/libzfs.h Wed Feb 10 17:49:22 2016 (r295475) @@ -62,6 +62,7 @@ int zfs_parsedev(struct zfs_devdesc *dev char *zfs_fmtdev(void *vdev); int zfs_probe_dev(const char *devname, uint64_t *pool_guid); int zfs_list(const char *name); +void init_zfs_bootenv(char *currdev); int zfs_bootenv(const char *name); int zfs_belist_add(const char *name); int zfs_set_env(void); Modified: stable/10/sys/boot/zfs/zfs.c ============================================================================== --- stable/10/sys/boot/zfs/zfs.c Wed Feb 10 16:49:20 2016 (r295474) +++ stable/10/sys/boot/zfs/zfs.c Wed Feb 10 17:49:22 2016 (r295475) @@ -709,6 +709,30 @@ zfs_list(const char *name) return (zfs_list_dataset(spa, objid)); } +void +init_zfs_bootenv(char *currdev) +{ + char *beroot; + + if (strlen(currdev) == 0) + return; + if(strncmp(currdev, "zfs:", 4) != 0) + return; + /* Remove the trailing : */ + currdev[strlen(currdev) - 1] = '\0'; + setenv("zfs_be_active", currdev, 1); + setenv("zfs_be_currpage", "1", 1); + /* Forward past zfs: */ + currdev = strchr(currdev, ':'); + currdev++; + /* Remove the last element (current bootenv) */ + beroot = strrchr(currdev, '/'); + if (beroot != NULL) + beroot[0] = '\0'; + beroot = currdev; + setenv("zfs_be_root", beroot, 1); +} + int zfs_bootenv(const char *name) { @@ -779,8 +803,15 @@ int zfs_belist_add(const char *name) { + /* Skip special datasets that start with a $ character */ + if (strncmp(name, "$", 1) == 0) { + return (0); + } /* Add the boot environment to the head of the SLIST */ zfs_be = malloc(sizeof(struct zfs_be_entry)); + if (zfs_be == NULL) { + return (ENOMEM); + } zfs_be->name = name; SLIST_INSERT_HEAD(&zfs_be_head, zfs_be, entries); zfs_env_count++;