svn commit: r294072 - in head/sys/boot: i386/loader userboot/userboot zfs
Allan Jude
allanjude at FreeBSD.org
Fri Jan 15 05:45:11 UTC 2016
Author: allanjude
Date: Fri Jan 15 05:45:10 2016
New Revision: 294072
URL: https://svnweb.freebsd.org/changeset/base/294072
Log:
Move init_zfs_bootenv to sys/boot/zfs/zfs.c instead of having a copy in each loader
While here, add a filter to ignore special datasets
MFC after: 3 days
Sponsored by: ScaleEngine Inc.
Modified:
head/sys/boot/i386/loader/main.c
head/sys/boot/userboot/userboot/main.c
head/sys/boot/zfs/libzfs.h
head/sys/boot/zfs/zfs.c
Modified: head/sys/boot/i386/loader/main.c
==============================================================================
--- head/sys/boot/i386/loader/main.c Fri Jan 15 05:38:27 2016 (r294071)
+++ head/sys/boot/i386/loader/main.c Fri Jan 15 05:45:10 2016 (r294072)
@@ -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
@@ -306,34 +305,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: head/sys/boot/userboot/userboot/main.c
==============================================================================
--- head/sys/boot/userboot/userboot/main.c Fri Jan 15 05:38:27 2016 (r294071)
+++ head/sys/boot/userboot/userboot/main.c Fri Jan 15 05:45:10 2016 (r294072)
@@ -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: head/sys/boot/zfs/libzfs.h
==============================================================================
--- head/sys/boot/zfs/libzfs.h Fri Jan 15 05:38:27 2016 (r294071)
+++ head/sys/boot/zfs/libzfs.h Fri Jan 15 05:45:10 2016 (r294072)
@@ -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: head/sys/boot/zfs/zfs.c
==============================================================================
--- head/sys/boot/zfs/zfs.c Fri Jan 15 05:38:27 2016 (r294071)
+++ head/sys/boot/zfs/zfs.c Fri Jan 15 05:45:10 2016 (r294072)
@@ -709,6 +709,32 @@ 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);
+ /* 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);
+}
+
int
zfs_bootenv(const char *name)
{
@@ -779,8 +805,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++;
More information about the svn-src-head
mailing list