From nobody Tue Oct 08 12:39:24 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 4XNFvc5zKGz5ZNcl; Tue, 08 Oct 2024 12:39:24 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XNFvc4pMdz4bXT; Tue, 8 Oct 2024 12:39:24 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728391164; 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=Ic5+2CibBVcIvVPUUoPONll1i6kh58EG6Re0p1vG9jw=; b=CCq98ANd90lKOB16jy/uLfQm1X0Jz3GCumQAxgCS7NPNxTQISWKnIz0hZ7N0SO5vRy6dfe ggllzxpL0UzUhyYmGIoy7TAkrtg1tqo/q7v77yEX0Q62nm5nylhgYYsv4zswWvzKquDiDg Hj82R4VDqqkIKZWAjazNUlaw9c+87x0KrcvGSYREm6zGei/SmKzbAfvD2g6NC4rZR0nBu6 I6wjjFIoW7Ar4kvL5W597gmJz+ZLkJxmaLGyoKMLMMkkn1RY03xDzBjYVj8ohb46qziAGd puxaes3HXHpq3KOD8ylbVBWuTmVtjPxD4mK1VVd+8p1P+XqRuHUutMhqTh0Huw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728391164; 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=Ic5+2CibBVcIvVPUUoPONll1i6kh58EG6Re0p1vG9jw=; b=IZOTsFZZSapNZBHXWpxBX7Omuho0PsUdi6SVMX/zZ9ORsCqOJePtoXat5GxFJxDseMOQE+ KDX1k5g/OpHlFWmf69n0aoNCQuPMOsVTK7kVw9bNEu08pLQvc8ayZd4DYnDJ75w2p29Eus q5vMcGdJ1d5ZJm1CV3B5DF0/IpVy8XQZ40tZkN9Efg9SNrl+qKNVZoIJFr90a5d4BSVW01 odWG6XV0mWP/4m+WINBfb7S8vuD8bJQcVgr3OQbPBP85qT38iC93beWnCWN9Ruj+fJrw/h vxWbltNdnRTwBYPENV0Y+AlAX4E2tqMqyASXkL1meM9tnfegrML7pGhOO56vVA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728391164; a=rsa-sha256; cv=none; b=wvMPPv9/ynl7UYRfO0tb0LbWzEHYzfygK6nVeaMXRZpY6e2017MjWUWab2Sp9d+zufjTu3 seSREt7LW4iWbR8dgrGeZFPhMxNBCYbe++1FjHOcLUBh3EeC28ylnoUMf02oqZtoyyWyvW 9+MLwqldNmi1625LqqwuH8RtJdhXAg8DDlQKq1/GlHZxOZ2jOW1oJN1HK+9paeg2HkpHZJ YJnqwnd2Vx0Z/eGDk+fiV8cegRgeUCy5CJXbeZrku5ZUOh8oKfdZO4RdoR4LP5uhxy0Je6 VeMR9RA0zunF+k+JUeLFfmLtrhmnrlM7kqAt2/WbCpo0VX7XFZkBEod7MP08jA== 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 4XNFvc4Q7dzWS1; Tue, 8 Oct 2024 12:39:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 498CdO5G012935; Tue, 8 Oct 2024 12:39:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 498CdOoV012932; Tue, 8 Oct 2024 12:39:24 GMT (envelope-from git) Date: Tue, 8 Oct 2024 12:39:24 GMT Message-Id: <202410081239.498CdOoV012932@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: bda73e441f25 - main - posix shm: add shm_get_path(9) 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: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-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: bda73e441f2576de5ad00856d758354c299a3f75 Auto-Submitted: auto-generated The branch main has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=bda73e441f2576de5ad00856d758354c299a3f75 commit bda73e441f2576de5ad00856d758354c299a3f75 Author: Konstantin Belousov AuthorDate: 2024-10-07 01:44:49 +0000 Commit: Konstantin Belousov CommitDate: 2024-10-08 12:38:03 +0000 posix shm: add shm_get_path(9) to calculate the posix shm path from the vm_object backing shm segment. Reviewed by: markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D46970 --- sys/kern/uipc_shm.c | 31 +++++++++++++++++++++++++++++++ sys/sys/mman.h | 1 + 2 files changed, 32 insertions(+) diff --git a/sys/kern/uipc_shm.c b/sys/kern/uipc_shm.c index cf98e1410074..f6861a3278ff 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -2208,3 +2208,34 @@ sys_shm_open2(struct thread *td, struct shm_open2_args *uap) return (kern_shm_open2(td, uap->path, uap->flags, uap->mode, uap->shmflags, NULL, uap->name)); } + +int +shm_get_path(struct vm_object *obj, char *path, size_t sz) +{ + struct shmfd *shmfd; + int error; + + error = 0; + shmfd = NULL; + sx_slock(&shm_dict_lock); + VM_OBJECT_RLOCK(obj); + if ((obj->flags & OBJ_POSIXSHM) == 0) { + error = EINVAL; + } else { + if (obj->type == shmfd_pager_type) + shmfd = obj->un_pager.swp.swp_priv; + else if (obj->type == OBJT_PHYS) + shmfd = obj->un_pager.phys.phys_priv; + if (shmfd == NULL) { + error = ENXIO; + } else { + strlcpy(path, shmfd->shm_path == NULL ? "anon" : + shmfd->shm_path, sz); + } + } + if (error != 0) + path[0] = '\0'; + VM_OBJECT_RUNLOCK(obj); + sx_sunlock(&shm_dict_lock); + return (error); +} diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 6ee2d5562db1..d2c7bdf1f022 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -310,6 +310,7 @@ void shm_drop(struct shmfd *shmfd); int shm_dotruncate(struct shmfd *shmfd, off_t length); bool shm_largepage(struct shmfd *shmfd); void shm_remove_prison(struct prison *pr); +int shm_get_path(struct vm_object *obj, char *path, size_t sz); extern struct fileops shm_ops;