tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Specifying root device in /etc/fstab
The ARM images currently contain an fstab entry that points to ld0. I want
to make this more generic as we may have different root devices and/or
root device units may not be consistent across reboots.
I came up with this simple patch to getfsspecname that allows ROOT=<part>
syntax for fs_spec. It uses the value of the kern.root_device sysctl to
construct a device path, so my fstab can have entries like this:
ROOT=a / ffs rw,noatime 1 1
ROOT=b none swap sw 0 0
ROOT=e /boot msdos rw 1 1
Thoughts? Suggestions?
Jared
Index: getfsspecname.c
===================================================================
RCS file: /cvsroot/src/lib/libutil/getfsspecname.c,v
retrieving revision 1.5
diff -u -p -r1.5 getfsspecname.c
--- getfsspecname.c 25 May 2014 13:46:07 -0000 1.5
+++ getfsspecname.c 30 Sep 2018 22:10:33 -0000
@@ -59,6 +59,30 @@ getfsspecname(char *buf, size_t bufsiz,
char *vname;
p = drives = vname = NULL;
+
+ if (strncasecmp(name, "ROOT=", 5) == 0) {
+ if (sysctlbyname("kern.root_device", NULL, &len, NULL, 0) == -1) {
+ savee = errno;
+ strlcpy(buf, "sysctl kern.root_device failed", bufsiz);
+ goto out;
+ }
+ dk = malloc(len);
+ if (dk == NULL) {
+ savee = errno;
+ strlcpy(buf, "malloc failed", bufsiz);
+ goto out;
+ }
+ if (sysctlbyname("kern.root_device", dk, &len, NULL, 0) == -1) {
+ savee = errno;
+ strlcpy(buf, "sysctl kern.root_device failed", bufsiz);
+ free(dk);
+ goto out;
+ }
+ snprintf(buf, bufsiz, "/dev/%s%s", dk, name + 5);
+ free(dk);
+ return buf;
+ }
+
if (strncasecmp(name, "NAME=", 5) != 0) {
#ifdef COMPAT_DKWEDGE
/*
Home |
Main Index |
Thread Index |
Old Index