From nobody Tue Oct 15 15:05:34 2024 X-Original-To: dev-commits-src-all@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 4XScq25RFdz5YYWX; Tue, 15 Oct 2024 15:05:34 +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 4XScq22KHYz46Hm; Tue, 15 Oct 2024 15:05:34 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729004734; 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=BMLy7BbQ5X7ECMnMXjNOQnoGpvb5AS/gHdUbNthL6do=; b=yrxe407d7l2OW3+mbFEuzpZPxo0i8VKBvc0QmI8721YONgigiKdFP5kS17TQy/Xwwtve+j 5O9/pbjEj7I1wKPsj7X+Zbz4NxPb0B+mOBKEHS1SOoV8YP01c2YiGPzrsvTSYA96vzNCLj Vyo5f7JfgZqLXHC2y/Ck5A+x+mrpxxdzGmhLsW+Xd3b5ZNsbw6bs+GynQKqiy45nt7oN6z HuOaVcbkTOzeXEF6BppTkod+n5xmaLKKrAyX1nfYzeRZcEFgs4tQCKoAD0jrPbPAm4wjMQ +5mcw9sEyr/oGFznlJ9/tIqmemN5eX8587w3W3rWgYYU4cI2N3PqyUi7CkruCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1729004734; 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=BMLy7BbQ5X7ECMnMXjNOQnoGpvb5AS/gHdUbNthL6do=; b=ZOrvbfMxjB8wFT29EqqjLwo6aK1YXrdcJ5t4XPgzdpshFfztZn2je406lbZ4AAgGvvyndK IT1NJUR1tyb6CyOX6gbGe8CAhoZPbOwitSONML8jAfOCijTLk3z0OxPi610+eSKoIMSCNO ZqPtpzESw4ASeqdVNG58WfE1g9t0lrLDs6eLw46MO5ypFp0MwDSgbRLJfsv+B+Sm1k0nVb tCD4cUeCTMK+kkzSlJF5lucZgMN449M1iE6sTJxu2xAG2R5E8+wWnqE4P5eNMBHxlX5sfw xBlRVm5aCqw5VeReW2VcoFjXxGDfK01WdKePXukRPQ/sz7qP23bqTyejYlaQgA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1729004734; a=rsa-sha256; cv=none; b=IXPHZ70EdC2KzpduCMjHf+aasaMVsVYNBw13lJ/+KSd3/2F7PdMJJyT9h02nSgAUqeS7Ze C7WqCtzCg6DyZF/S3TdS9rTd+acVqxRR11ujsPEz64F4S3QcIR5HX7nT337E2orr7DH7dT oeAvx0qDHTUCdWD1qhJ4on78Tcv8SV6IUlGAOoAn7GVjkm/ihZrIjucXkTZ+IPr4qWDsNA nPK2KaE5qVFtGxYQZAbX5KxSVuKw3qTCnWv5dwnauRnCVry7SpFcaDtGKUK9Fs3ED7wniU sM9rpxY9YAKe7YGWSjgmaI8myWoGL6U0AqDk8dXVV//xdQqIx8MHNxnwGWWnNA== 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 4XScq21xSwzR8Z; Tue, 15 Oct 2024 15:05:34 +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 49FF5YB2089609; Tue, 15 Oct 2024 15:05:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FF5YsC089606; Tue, 15 Oct 2024 15:05:34 GMT (envelope-from git) Date: Tue, 15 Oct 2024 15:05:34 GMT Message-Id: <202410151505.49FF5YsC089606@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Konstantin Belousov Subject: git: 64de7b789b3d - stable/14 - posix shm: add shm_get_path(9) List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 64de7b789b3d9fb03dfac93fa8c3ba6fa27bcd82 Auto-Submitted: auto-generated The branch stable/14 has been updated by kib: URL: https://cgit.FreeBSD.org/src/commit/?id=64de7b789b3d9fb03dfac93fa8c3ba6fa27bcd82 commit 64de7b789b3d9fb03dfac93fa8c3ba6fa27bcd82 Author: Konstantin Belousov AuthorDate: 2024-10-07 01:44:49 +0000 Commit: Konstantin Belousov CommitDate: 2024-10-15 14:50:17 +0000 posix shm: add shm_get_path(9) (cherry picked from commit bda73e441f2576de5ad00856d758354c299a3f75) --- 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 52a569931b01..8334d7eb3264 100644 --- a/sys/kern/uipc_shm.c +++ b/sys/kern/uipc_shm.c @@ -2196,3 +2196,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 7eb38a5f59d0..36973b941e61 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;