summaryrefslogtreecommitdiffstats
path: root/sys/fs/devfs/devfs_devs.c
diff options
context:
space:
mode:
authorjh <jh@FreeBSD.org>2010-09-27 18:20:56 +0000
committerjh <jh@FreeBSD.org>2010-09-27 18:20:56 +0000
commit400a76c2ba6b2165278b9c942a6c7a48a78f124f (patch)
treeeff74ceea454ebea211167dc46d11a36f767385d /sys/fs/devfs/devfs_devs.c
parentb6e78e30f23dbed7263727af46739f94ef85fd86 (diff)
downloadFreeBSD-src-400a76c2ba6b2165278b9c942a6c7a48a78f124f.zip
FreeBSD-src-400a76c2ba6b2165278b9c942a6c7a48a78f124f.tar.gz
Add a new function devfs_dev_exists() to be able to find out if a
specific devfs path already exists. The function will be used from kern_conf.c to detect duplicate device registrations. Callers must hold the devmtx mutex. Reviewed by: kib
Diffstat (limited to 'sys/fs/devfs/devfs_devs.c')
-rw-r--r--sys/fs/devfs/devfs_devs.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/sys/fs/devfs/devfs_devs.c b/sys/fs/devfs/devfs_devs.c
index 99b33ec..52e6567 100644
--- a/sys/fs/devfs/devfs_devs.c
+++ b/sys/fs/devfs/devfs_devs.c
@@ -142,6 +142,27 @@ devfs_alloc(int flags)
return (cdev);
}
+int
+devfs_dev_exists(const char *name)
+{
+ struct cdev_priv *cdp;
+
+ mtx_assert(&devmtx, MA_OWNED);
+
+ TAILQ_FOREACH(cdp, &cdevp_list, cdp_list) {
+ if ((cdp->cdp_flags & CDP_ACTIVE) == 0)
+ continue;
+ if (devfs_pathpath(cdp->cdp_c.si_name, name) != 0)
+ return (1);
+ if (devfs_pathpath(name, cdp->cdp_c.si_name) != 0)
+ return (1);
+ }
+ if (devfs_dir_find(name) != 0)
+ return (1);
+
+ return (0);
+}
+
void
devfs_free(struct cdev *cdev)
{
OpenPOWER on IntegriCloud