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.
This commit is contained in:
parent
7bd249ecf0
commit
fbe958861e
@ -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
|
||||
|
@ -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
|
||||
@ -199,32 +198,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)
|
||||
{
|
||||
|
@ -62,6 +62,7 @@ int zfs_parsedev(struct zfs_devdesc *dev, const char *devspec,
|
||||
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);
|
||||
|
@ -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++;
|
||||
|
Loading…
Reference in New Issue
Block a user