summaryrefslogtreecommitdiffstats
path: root/sys/fs/devfs/devfs_devs.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2005-08-16 19:25:02 +0000
committerphk <phk@FreeBSD.org>2005-08-16 19:25:02 +0000
commit8a3fe9480492cbc41bbe10556f6b552f1004ce44 (patch)
treecc96138f85c7f62c3ff5ee1faff169dea0677c20 /sys/fs/devfs/devfs_devs.c
parente89ebd411994ee67633800f6278c77c01947520f (diff)
downloadFreeBSD-src-8a3fe9480492cbc41bbe10556f6b552f1004ce44.zip
FreeBSD-src-8a3fe9480492cbc41bbe10556f6b552f1004ce44.tar.gz
Collect the devfs related sysctls in one place
Diffstat (limited to 'sys/fs/devfs/devfs_devs.c')
-rw-r--r--sys/fs/devfs/devfs_devs.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index 37d3d90..2329b84 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -71,6 +71,38 @@ SYSCTL_UINT(_vfs_devfs, OID_AUTO, inodes, CTLFLAG_RD,
SYSCTL_UINT(_vfs_devfs, OID_AUTO, topinode, CTLFLAG_RD,
&devfs_topino, 0, "DEVFS highest inode#");
+/*
+ * Helper sysctl for devname(3). We're given a struct cdev * and return
+ * the name, if any, registered by the device driver.
+ */
+static int
+sysctl_devname(SYSCTL_HANDLER_ARGS)
+{
+ int error;
+ dev_t ud;
+ struct cdev *dev, **dp;
+
+ error = SYSCTL_IN(req, &ud, sizeof (ud));
+ if (error)
+ return (error);
+ if (ud == NODEV)
+ return(EINVAL);
+ dp = devfs_itod(ud);
+ if (dp == NULL)
+ return(ENOENT);
+ dev = *dp;
+ if (dev == NULL)
+ return(ENOENT);
+ return(SYSCTL_OUT(req, dev->si_name, strlen(dev->si_name) + 1));
+ return (error);
+}
+
+SYSCTL_PROC(_kern, OID_AUTO, devname, CTLTYPE_OPAQUE|CTLFLAG_RW|CTLFLAG_ANYBODY,
+ NULL, 0, sysctl_devname, "", "devname(3) handler");
+
+SYSCTL_INT(_debug_sizeof, OID_AUTO, cdev, CTLFLAG_RD,
+ 0, sizeof(struct cdev), "sizeof(struct cdev)");
+
static int *
devfs_itor(int inode)
{
OpenPOWER on IntegriCloud