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
This commit is contained in:
Jaakko Heinonen 2010-09-27 18:20:56 +00:00
parent d318c565d7
commit 47bcfb6422
2 changed files with 22 additions and 0 deletions

View File

@ -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)
{

View File

@ -72,6 +72,7 @@ struct cdev_priv {
#define cdev2priv(c) member2struct(cdev_priv, cdp_c, c)
struct cdev *devfs_alloc(int);
int devfs_dev_exists(const char *);
void devfs_free(struct cdev *);
void devfs_create(struct cdev *dev);
void devfs_destroy(struct cdev *dev);