From nobody Sat Mar 23 06:59:15 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4V1qn020pMz5Djfv; Sat, 23 Mar 2024 06:59:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4V1qmz6JMqz4KMd; Sat, 23 Mar 2024 06:59:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711177155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S0xZSxcETWCXeSgqz29PwRJyXWz1UdFGUT44PdT8a7U=; b=DQY73XmDmHN+1kTmwQf8FYvEpzqMR0KRWvTfUhZZ3IKcZjY1lZOC2pPDcNe/cr9x0/LUMD Pvyt6og4PXyVCgvF/I2qRPoMTrlSxUS5MB2vbmDLuH9IXCEHBkzs0GKbEe5+aVfgwvPV+l 0ScS3X9HlUcPJt7Sg1Y0FHEpQxpBf+GxJyUbqSQnYT5YGKqyTCGbYaq2oib5y5MGsuEKmR ZaTL7yWryDosWOXWC7be/JjOK2F+J2wV+jB4MJT0sh7+ueJOG6YZZPQy+PiQi67ZGM8Bs/ 0m6FBPzyn/6gaQW9PR/bRFWS/nAQlg3Nl0b20oYq0nAt8m/2QE2I1YdscM24Ig== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1711177155; a=rsa-sha256; cv=none; b=dasUTbC0l52N56xxYD1P3/GqDpZ2ZbENFiB5QNgRbsLZY0a3X0VHNYNQ4qxLeUk1WLWjGC AeFuoEXZLikokCfwrbSvGIzWb8NyEwiL7iPfCwi8p8DMYzXLfk7SFp7jQGoUHBDRYvL8hP 4JQEm1xdiz9mSWivyNl3GeUuB2CngODYZ1vPa7uklhiUDI4JvKU0/Kpi8vjtlOnk/TxMHh DCTxLeBEaT66bX88uWxPq4a9Dfg2ptU6c716cUFN032oinmQjtY1q2TTsODFkgu+Qp9edk ggBwivx+uPErN0TP9jfbo1wtqssA/kCZ5Dydhfl5WmQfvytN/0MQ5tGM1qFygQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1711177155; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=S0xZSxcETWCXeSgqz29PwRJyXWz1UdFGUT44PdT8a7U=; b=ZjToPmoC+BtTwVl+eyHgFPULRXUskJXGWjzpg/ap/9V9vCai97cxcTqMWUMAVXNy0183ut 2e2icf4H7nloVEaGIOpl8PS5TvP7BBPrIz+LvhoU91VzygqaYS2RwxfxkVl1RvmuiQQ0/k /HETAiritmh+OUciZLF7O7otvmgH1rxZZes8AmoR3EVpdwvxe284XF+1ourluX4r1m93Hu s9MN3ASymqq/ZFYGCRge7SS/Her4eyBS1uUbgG5f1yzvbNaRnj1BBoCqGwT5bLQKfrhMMp G88LqcLTdKlihlzuR9S5Vv39wBxKCsCrUSp4jll4PNbA1mrCzw3qhXl/DfdMyA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4V1qmz5X5gzdJ3; Sat, 23 Mar 2024 06:59:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42N6xFI6065481; Sat, 23 Mar 2024 06:59:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42N6xFRS065478; Sat, 23 Mar 2024 06:59:15 GMT (envelope-from git) Date: Sat, 23 Mar 2024 06:59:15 GMT Message-Id: <202403230659.42N6xFRS065478@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Konstantin Belousov Subject: git: d3efbe0132b2 - main - cdevpriv(9): add iterator List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kib X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: d3efbe0132b24e8660df836905cda7662f85a154 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=d3efbe0132b24e8660df836905cda7662f85a154 commit d3efbe0132b24e8660df836905cda7662f85a154 Author: Konstantin Belousov AuthorDate: 2024-03-22 02:58:00 +0000 Commit: Konstantin Belousov CommitDate: 2024-03-23 06:59:00 +0000 cdevpriv(9): add iterator Reviewed by: christos Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44469 --- 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 3b8a624fe620..a35f6dbf9520 100644 --- a/sys/fs/devfs/devfs_vnops.c +++ b/sys/fs/devfs/devfs_vnops.c @@ -177,6 +177,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 d7a33ed10afa..f34fd43cfe24 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -319,6 +319,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);