Module Name: src
Committed By: jmcneill
Date: Sat Oct 6 13:09:53 UTC 2018
Modified Files:
src/etc/rc.d: resize_root
src/lib/libutil: getfsspecname.3 getfsspecname.c
src/share/man/man5: fstab.5
Log Message:
If fs_spec starts with the special string "ROOT.", replace it with a device
path derived from the value of the kern.root_device sysctl.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/etc/rc.d/resize_root
cvs rdiff -u -r1.5 -r1.6 src/lib/libutil/getfsspecname.3 \
src/lib/libutil/getfsspecname.c
cvs rdiff -u -r1.43 -r1.44 src/share/man/man5/fstab.5
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/etc/rc.d/resize_root
diff -u src/etc/rc.d/resize_root:1.3 src/etc/rc.d/resize_root:1.4
--- src/etc/rc.d/resize_root:1.3 Tue Apr 7 18:02:11 2015
+++ src/etc/rc.d/resize_root Sat Oct 6 13:09:53 2018
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: resize_root,v 1.3 2015/04/07 18:02:11 jmcneill Exp $
+# $NetBSD: resize_root,v 1.4 2018/10/06 13:09:53 jmcneill Exp $
#
# PROVIDE: resize_root
@@ -45,6 +45,7 @@ resize_root_start()
# skip comment or blank line
case "${fs_spec}" in
\#*|'') continue ;;
+ ROOT\.*) fs_spec="/dev/$(sysctl -n kern.root_device)${fs_spec#ROOT.}" ;;
esac
# skip non-root
Index: src/lib/libutil/getfsspecname.3
diff -u src/lib/libutil/getfsspecname.3:1.5 src/lib/libutil/getfsspecname.3:1.6
--- src/lib/libutil/getfsspecname.3:1.5 Sat Jun 13 19:52:58 2015
+++ src/lib/libutil/getfsspecname.3 Sat Oct 6 13:09:53 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: getfsspecname.3,v 1.5 2015/06/13 19:52:58 dholland Exp $
+.\" $NetBSD: getfsspecname.3,v 1.6 2018/10/06 13:09:53 jmcneill Exp $
.\"
.\" Copyright (c) 2012 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -28,7 +28,7 @@
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.\"
-.Dd August 18, 2014
+.Dd October 6, 2018
.Dt GETFSSPECNAME 3
.Os
.Sh NAME
@@ -65,6 +65,26 @@ is copied
to
.Fa buf
and returned.
+.Pp
+If the
+.Fa spec
+argument starts with
+.Dq ROOT. ,
+a path in the form
+.Dq /dev/[root_device][suffix]
+is copied to
+.Fa buf ,
+where
+.Bq root_device
+is the value of the
+.Dq kern.root_device
+sysctl and
+.Bq suffix
+is the characters following
+.Dq ROOT.
+in the
+.Fa spec
+argument.
.Sh RETURN VALUES
On success the absolute pathname of the underlying wedge device is returned,
or the original
Index: src/lib/libutil/getfsspecname.c
diff -u src/lib/libutil/getfsspecname.c:1.5 src/lib/libutil/getfsspecname.c:1.6
--- src/lib/libutil/getfsspecname.c:1.5 Sun May 25 13:46:07 2014
+++ src/lib/libutil/getfsspecname.c Sat Oct 6 13:09:53 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: getfsspecname.c,v 1.5 2014/05/25 13:46:07 christos Exp $ */
+/* $NetBSD: getfsspecname.c,v 1.6 2018/10/06 13:09:53 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
-__RCSID("$NetBSD: getfsspecname.c,v 1.5 2014/05/25 13:46:07 christos Exp $");
+__RCSID("$NetBSD: getfsspecname.c,v 1.6 2018/10/06 13:09:53 jmcneill Exp $");
#include <sys/types.h>
#include <sys/ioctl.h>
@@ -59,6 +59,28 @@ getfsspecname(char *buf, size_t bufsiz,
char *vname;
p = drives = vname = NULL;
+
+ /*
+ * If the name starts with "ROOT.", replace it with "/dev/<root_device>",
+ * where <root_device> is the value of the kern.root_device sysctl. Any
+ * characters after the special "ROOT." token are appended to the end
+ * of this path.
+ */
+ if (strncasecmp(name, "ROOT.", 5) == 0 && strchr(name, ':') == NULL) {
+ static const int mib_root[] = { CTL_KERN, KERN_ROOT_DEVICE };
+ static const int mib_rootlen = __arraycount(mib_root);
+
+ strlcpy(buf, "/dev/", bufsiz);
+ len = bufsiz - 5;
+ if (sysctl(mib_root, mib_rootlen, buf + 5, &len, NULL, 0) == -1) {
+ savee = errno;
+ strlcpy(buf, "sysctl kern.root_device failed", bufsiz);
+ goto out;
+ }
+ strlcat(buf, name + 5, bufsiz);
+ return buf;
+ }
+
if (strncasecmp(name, "NAME=", 5) != 0) {
#ifdef COMPAT_DKWEDGE
/*
Index: src/share/man/man5/fstab.5
diff -u src/share/man/man5/fstab.5:1.43 src/share/man/man5/fstab.5:1.44
--- src/share/man/man5/fstab.5:1.43 Mon Dec 21 13:15:04 2015
+++ src/share/man/man5/fstab.5 Sat Oct 6 13:09:53 2018
@@ -1,4 +1,4 @@
-.\" $NetBSD: fstab.5,v 1.43 2015/12/21 13:15:04 ryoon Exp $
+.\" $NetBSD: fstab.5,v 1.44 2018/10/06 13:09:53 jmcneill Exp $
.\"
.\" Copyright (c) 1980, 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)fstab.5 8.1 (Berkeley) 6/5/93
.\"
-.Dd December 21, 2015
+.Dd October 6, 2018
.Dt FSTAB 5
.Os
.Sh NAME
@@ -91,6 +91,16 @@ wedge partitions are searched for one th
.Ar <value>
and the device corresponding to it is selected.
.Pp
+If the first field starts with the prefix
+.Dq ROOT.
+the prefix is replaced with
+.Dq /dev/[root_device] ,
+where
+.Bq root_device
+is the value of the
+.Dq kern.root_device
+sysctl.
+.Pp
The second field,
.Pq Fa fs_file ,
describes the mount point for the file system.