git: 8d9ed1dd5088 - stable/13 - cdevpriv(9): add iterator
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 30 Mar 2024 08:32:52 UTC
The branch stable/13 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=8d9ed1dd5088901a0000c30b6a5ee6a38beb491d commit 8d9ed1dd5088901a0000c30b6a5ee6a38beb491d Author: Konstantin Belousov <kib@FreeBSD.org> AuthorDate: 2024-03-22 02:58:00 +0000 Commit: Konstantin Belousov <kib@FreeBSD.org> CommitDate: 2024-03-30 08:32:23 +0000 cdevpriv(9): add iterator (cherry picked from commit d3efbe0132b24e8660df836905cda7662f85a154) --- sys/fs/devfs/devfs_vnops.c | 20 ++++++++++++++++++++ sys/sys/conf.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c index 45c72438f752..919ab2ff4381 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -182,6 +182,26 @@ devfs_set_cdevpriv(void *priv, d_priv_dtor_t *priv_dtr) return (error); } +int +devfs_foreach_cdevpriv(struct cdev *dev, int (*cb)(void *data, void *arg), + void *arg) +{ + struct cdev_priv *cdp; + struct cdev_privdata *p; + int error; + + cdp = cdev2priv(dev); + error = 0; + mtx_lock(&cdevpriv_mtx); + LIST_FOREACH(p, &cdp->cdp_fdpriv, cdpd_list) { + error = cb(p->cdpd_data, arg); + if (error != 0) + break; + } + mtx_unlock(&cdevpriv_mtx); + return (error); +} + void devfs_destroy_cdevpriv(struct cdev_privdata *p) { diff --git a/sys/sys/conf.h b/sys/sys/conf.h index ac2af96e5ad1..ab61171ab24e 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -322,6 +322,8 @@ typedef void d_priv_dtor_t(void *data); int devfs_get_cdevpriv(void **datap); int devfs_set_cdevpriv(void *priv, d_priv_dtor_t *dtr); void devfs_clear_cdevpriv(void); +int devfs_foreach_cdevpriv(struct cdev *dev, + int (*cb)(void *data, void *arg), void *arg); ino_t devfs_alloc_cdp_inode(void); void devfs_free_cdp_inode(ino_t ino);