summaryrefslogtreecommitdiffstats
path: root/sys/kern
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2003-02-22 05:01:12 +0000
committerrwatson <rwatson@FreeBSD.org>2003-02-22 05:01:12 +0000
commit9f4f9a305c8f3562d5c24a257ad55351baedc94f (patch)
treeda275c9f06ed4d0d2ddb992d10af1c2570a83a82 /sys/kern
parent9ed5a11f37a83d8330dd79757d41fe9b50a0fb42 (diff)
downloadFreeBSD-src-9f4f9a305c8f3562d5c24a257ad55351baedc94f.zip
FreeBSD-src-9f4f9a305c8f3562d5c24a257ad55351baedc94f.tar.gz
Export the name of the device used to mount the root file system as
kern.rootdev. If rootdev is undefined (NFS mount, etc), export an empty string. Desired by: peter
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/vfs_mount.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/sys/kern/vfs_mount.c b/sys/kern/vfs_mount.c
index 9c47ceb..a7efa34 100644
--- a/sys/kern/vfs_mount.c
+++ b/sys/kern/vfs_mount.c
@@ -150,6 +150,30 @@ char *rootdevnames[2] = {NULL, NULL};
static int setrootbyname(char *name);
dev_t rootdev = NODEV;
+/*
+ * Has to be dynamic as the value of rootdev can change; however, it can't
+ * change after the root is mounted, so a user process can't access this
+ * sysctl until after the value is unchangeable.
+ */
+static int
+sysctl_rootdev(SYSCTL_HANDLER_ARGS)
+{
+ int error;
+
+ /* _RD prevents this from happening. */
+ KASSERT(req->newptr == NULL, ("Attempt to change root device name"));
+
+ if (rootdev != NODEV)
+ error = sysctl_handle_string(oidp, rootdev->si_name, 0, req);
+ else
+ error = sysctl_handle_string(oidp, "", 0, req);
+
+ return (error);
+}
+
+SYSCTL_PROC(_kern, OID_AUTO, rootdev, CTLTYPE_STRING | CTLFLAG_RD,
+ 0, 0, sysctl_rootdev, "A", "Root file system device");
+
/* Remove one mount option. */
static void
vfs_freeopt(struct vfsoptlist *opts, struct vfsopt *opt)
OpenPOWER on IntegriCloud