From nobody Mon Oct 11 09:15:53 2021 X-Original-To: dev-commits-src-branches@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 BE37317F956C; Mon, 11 Oct 2021 09:15:57 +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 4HSY7G21Gqz3NFw; Mon, 11 Oct 2021 09:15:53 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 8C0511E79E; Mon, 11 Oct 2021 09:15:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 19B9FrgB009579; Mon, 11 Oct 2021 09:15:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 19B9FrTl009578; Mon, 11 Oct 2021 09:15:53 GMT (envelope-from git) Date: Mon, 11 Oct 2021 09:15:53 GMT Message-Id: <202110110915.19B9FrTl009578@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mateusz Guzik Subject: git: e6014341647f - stable/13 - fd: add pwd_hold_proc List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e6014341647f9a45dab9d09f57d475c50137e6b6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=e6014341647f9a45dab9d09f57d475c50137e6b6 commit e6014341647f9a45dab9d09f57d475c50137e6b6 Author: Mateusz Guzik AuthorDate: 2021-09-30 10:49:51 +0000 Commit: Mateusz Guzik CommitDate: 2021-10-11 09:13:03 +0000 fd: add pwd_hold_proc (cherry picked from commit 85c855d31b18d7a8ab534259f27444c81b6ec797) --- sys/kern/kern_descrip.c | 20 ++++++++++++++++++++ sys/sys/filedesc.h | 1 + 2 files changed, 21 insertions(+) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 58c2d1939dba..755b5df51c6a 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -3791,6 +3791,26 @@ pwd_hold(struct thread *td) return (pwd); } +struct pwd * +pwd_hold_proc(struct proc *p) +{ + struct pwddesc *pdp; + struct pwd *pwd; + + PROC_ASSERT_HELD(p); + PROC_LOCK(p); + pdp = pdhold(p); + MPASS(pdp != NULL); + PROC_UNLOCK(p); + + PWDDESC_XLOCK(pdp); + pwd = pwd_hold_pwddesc(pdp); + MPASS(pwd != NULL); + PWDDESC_XUNLOCK(pdp); + pddrop(pdp); + return (pwd); +} + static struct pwd * pwd_alloc(void) { diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 7f18d8a2286c..f17fdf601ba1 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -341,6 +341,7 @@ void pwd_set_rootvnode(void); struct pwd *pwd_hold_pwddesc(struct pwddesc *pdp); bool pwd_hold_smr(struct pwd *pwd); +struct pwd *pwd_hold_proc(struct proc *p); struct pwd *pwd_hold(struct thread *td); void pwd_drop(struct pwd *pwd); static inline void