aboutsummaryrefslogtreecommitdiff
path: root/stand/common
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2023-01-11 22:14:02 +0000
committerWarner Losh <imp@FreeBSD.org>2023-01-11 22:15:14 +0000
commit1c1783d66bc81ebd0c1304b1f613a9403c073915 (patch)
tree91a3e33c49380c109f4899a3c0d14390d082802e /stand/common
parent39633fc1731c3feeed36aa452bbdfb7968a86383 (diff)
stand: Create common gen_setcurrdev and replace code
Replace 4 identical copies of *_setcurrdev with gen_setcurrdev to avoid having to create a 5th copy. uboot_setcurrdev is actually different and needs to remain separate (even though it's quite similar). Sponsored by: Netflix Reviewed by: fuz@fuz.su, kevans Differential Revision: https://reviews.freebsd.org/D38003
Diffstat (limited to 'stand/common')
-rw-r--r--stand/common/bootstrap.h3
-rw-r--r--stand/common/misc.c16
2 files changed, 18 insertions, 1 deletions
diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h
index bbe97e80323b..b16625774ce5 100644
--- a/stand/common/bootstrap.h
+++ b/stand/common/bootstrap.h
@@ -415,7 +415,8 @@ int nvstore_set_var_from_string(void *, const char *, const char *,
int nvstore_unset_var(void *, const char *);
/* common code to set currdev variable. */
-extern int mount_currdev(struct env_var *, int, const void *);
+int gen_setcurrdev(struct env_var *ev, int flags, const void *value);
+int mount_currdev(struct env_var *, int, const void *);
#ifndef CTASSERT
#define CTASSERT(x) _Static_assert(x, "compile-time assertion failed")
diff --git a/stand/common/misc.c b/stand/common/misc.c
index 9cb5550344ca..e1945b24be5a 100644
--- a/stand/common/misc.c
+++ b/stand/common/misc.c
@@ -201,3 +201,19 @@ int mount_currdev(struct env_var *ev, int flags, const void *value)
}
return (rv);
}
+
+/*
+ * Set currdev to suit the value being supplied in (value)
+ */
+int
+gen_setcurrdev(struct env_var *ev, int flags, const void *value)
+{
+ struct devdesc *ncurr;
+ int rv;
+
+ if ((rv = devparse(&ncurr, value, NULL)) != 0)
+ return (rv);
+ free(ncurr);
+
+ return (mount_currdev(ev, flags, value));
+}