From nobody Tue May 21 23:59:18 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 4VkWcl0RWJz5L6sm; Tue, 21 May 2024 23:59:19 +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 4VkWck7379z4lFR; Tue, 21 May 2024 23:59:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716335959; 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=3gUOb8RSSY32V9pulHMXADoZD1DmINIFkvWrP4Cyj0k=; b=ZraUXOCR1LzM5xD43d1Gq0E7Q1JN9Kqvz4CHAkG7Lv17qnqo+D3nEB8rNlPebL1M5X5RD+ 0l90ecR3RgC+HrS1wpEs/9r3Um/f11UDI3mtl+kUSj6jWCEXYfJY/KiIzNu4iNirakNNhj ORTbVzY7pDYPYwburJMOP8qwCxUn9yE543y+szM4nEEpHFcm2CD/a4ou9JkzSA2INTDBC4 5SszxsSlZgT3Wn69zcXBdLpLmqTwLoFLB0KGg1eRjeC8exuuLtVoyR7vNNeejsrpLTob4I XTm7Fgw9RFFRdIE4zoqtYeQqbN6fE7sTGSUVYiyYgLC81zWIt7jA4SCif9d1DQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716335959; a=rsa-sha256; cv=none; b=XEPe+IU4XON8onEk2Tnz/J4XDu0vjUkKrmBWeNv8aRHJ2/RI4OPNpUh71yVLD8/Vch7RfY sD8sYepMo/RHz2wl0Kd/99TesRXJVgQ5hsSEfgYa5x2lVHIh1YhWq0JbNvl8CJBZ3lNh9c ZchJBZ0b8O4QncocFsk2lrIENltefDQq9g/cAojr+biyEVDeybQEVQORiRX2NU1CQWFVhw OM67esO3lCtgCSslSoPeQclZYRCMPOFxMWNIneETlL7+GNfdbOuxGhKHfcMCvz6RNha2ff ElUoKkykg2PjQSRrhLsAYI9srF25R4bRYP8djrlwkpYFNEd6bWrr8BGJ9gl95w== 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=1716335959; 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=3gUOb8RSSY32V9pulHMXADoZD1DmINIFkvWrP4Cyj0k=; b=iCa8UsbijeTLzuqTwHipAv80EkV396Ia8SIQ+rR5C9TgyEVg1Fq3Hqc9gmngUoaMTWjEO/ IIDOBag28+XllQEDVmyeGeNdRmPJOrdHjtbVSnVt5610JkuevJLqtbo0gFl62FI5K+wwFI vEMaj935G7SXme30drAetwmYOl9KNZLrN7Bl3M7o+3wy/v9hqzt079vdVUDQgD6ylku9kz kfqfqamyDRg+WiJHk/0ztgalu4635P8V/dBKrLZEwns8vEBg5Bs1FKe85G0TqXYXT+9/4o wTquLwTj2h2BninxJtcT4WNx7WHNkM+wEx0W6YebLWfJdOvZaeQX7N5UiSz6gw== 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 4VkWck6ZMMzjXD; Tue, 21 May 2024 23:59:18 +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 44LNxIT9032848; Tue, 21 May 2024 23:59:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44LNxIYv032845; Tue, 21 May 2024 23:59:18 GMT (envelope-from git) Date: Tue, 21 May 2024 23:59:18 GMT Message-Id: <202405212359.44LNxIYv032845@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 25a04527b706 - main - linprocfs: Add support for proc/sysvipc/{msg,sem,shm} 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: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 25a04527b706577dac781fc249e3dbe948ccae60 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=25a04527b706577dac781fc249e3dbe948ccae60 commit 25a04527b706577dac781fc249e3dbe948ccae60 Author: Ricardo Branco AuthorDate: 2024-05-12 20:26:15 +0000 Commit: Warner Losh CommitDate: 2024-05-21 23:58:28 +0000 linprocfs: Add support for proc/sysvipc/{msg,sem,shm} Reviewed by: imp,kib Pull Request: https://github.com/freebsd/freebsd-src/pull/1232 --- sys/compat/linprocfs/linprocfs.c | 137 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c index 391d5f679ee5..bfa2074a78d3 100644 --- a/sys/compat/linprocfs/linprocfs.c +++ b/sys/compat/linprocfs/linprocfs.c @@ -2092,6 +2092,134 @@ linprocfs_domax_map_cnt(PFS_FILL_ARGS) return (0); } +/* + * Filler function for proc/sysvipc/msg + */ +static int +linprocfs_dosysvipc_msg(PFS_FILL_ARGS) +{ + struct msqid_kernel *msqids; + size_t id, size; + int error; + + sbuf_printf(sb, + "%10s %10s %4s %10s %10s %5s %5s %5s %5s %5s %5s %10s %10s %10s\n", + "key", "msqid", "perms", "cbytes", "qnum", "lspid", "lrpid", + "uid", "gid", "cuid", "cgid", "stime", "rtime", "ctime"); + + error = kern_get_msqids(curthread, &msqids, &size); + if (error != 0) + return (error); + + for (id = 0; id < size; id++) { + if (msqids[id].u.msg_qbytes == 0) + continue; + sbuf_printf(sb, + "%10d %10lu %4o %10lu %10lu %5u %5u %5u %5u %5u %5u %jd %jd %jd\n", + (int)msqids[id].u.msg_perm.key, + IXSEQ_TO_IPCID(id, msqids[id].u.msg_perm), + msqids[id].u.msg_perm.mode, + msqids[id].u.msg_cbytes, + msqids[id].u.msg_qnum, + msqids[id].u.msg_lspid, + msqids[id].u.msg_lrpid, + msqids[id].u.msg_perm.uid, + msqids[id].u.msg_perm.gid, + msqids[id].u.msg_perm.cuid, + msqids[id].u.msg_perm.cgid, + (intmax_t)msqids[id].u.msg_stime, + (intmax_t)msqids[id].u.msg_rtime, + (intmax_t)msqids[id].u.msg_ctime); + } + + free(msqids, M_TEMP); + return (0); +} + +/* + * Filler function for proc/sysvipc/sem + */ +static int +linprocfs_dosysvipc_sem(PFS_FILL_ARGS) +{ + struct semid_kernel *semids; + size_t id, size; + int error; + + sbuf_printf(sb, "%10s %10s %4s %10s %5s %5s %5s %5s %10s %10s\n", + "key", "semid", "perms", "nsems", "uid", "gid", "cuid", "cgid", + "otime", "ctime"); + + error = kern_get_sema(curthread, &semids, &size); + if (error != 0) + return (error); + + for (id = 0; id < size; id++) { + if ((semids[id].u.sem_perm.mode & SEM_ALLOC) == 0) + continue; + sbuf_printf(sb, + "%10d %10lu %4o %10u %5u %5u %5u %5u %jd %jd\n", + (int)semids[id].u.sem_perm.key, + IXSEQ_TO_IPCID(id, semids[id].u.sem_perm), + semids[id].u.sem_perm.mode, + semids[id].u.sem_nsems, + semids[id].u.sem_perm.uid, + semids[id].u.sem_perm.gid, + semids[id].u.sem_perm.cuid, + semids[id].u.sem_perm.cgid, + (intmax_t)semids[id].u.sem_otime, + (intmax_t)semids[id].u.sem_ctime); + } + + free(semids, M_TEMP); + return (0); +} + +/* + * Filler function for proc/sysvipc/shm + */ +static int +linprocfs_dosysvipc_shm(PFS_FILL_ARGS) +{ + struct shmid_kernel *shmids; + size_t id, size; + int error; + + sbuf_printf(sb, + "%10s %10s %s %21s %5s %5s %5s %5s %5s %5s %5s %10s %10s %10s %21s %21s\n", + "key", "shmid", "perms", "size", "cpid", "lpid", "nattch", "uid", + "gid", "cuid", "cgid", "atime", "dtime", "ctime", "rss", "swap"); + + error = kern_get_shmsegs(curthread, &shmids, &size); + if (error != 0) + return (error); + + for (id = 0; id < size; id++) { + if ((shmids[id].u.shm_perm.mode & SHMSEG_ALLOCATED) == 0) + continue; + sbuf_printf(sb, + "%10d %10lu %4o %21zu %5u %5u %5u %5u %5u %5u %5u %jd %jd %jd %21d %21d\n", + (int)shmids[id].u.shm_perm.key, + IXSEQ_TO_IPCID(id, shmids[id].u.shm_perm), + shmids[id].u.shm_perm.mode, + shmids[id].u.shm_segsz, + shmids[id].u.shm_cpid, + shmids[id].u.shm_lpid, + shmids[id].u.shm_nattch, + shmids[id].u.shm_perm.uid, + shmids[id].u.shm_perm.gid, + shmids[id].u.shm_perm.cuid, + shmids[id].u.shm_perm.cgid, + (intmax_t)shmids[id].u.shm_atime, + (intmax_t)shmids[id].u.shm_dtime, + (intmax_t)shmids[id].u.shm_ctime, + 0, 0); /* XXX rss & swp are not supported */ + } + + free(shmids, M_TEMP); + return (0); +} + /* * Constructor */ @@ -2241,6 +2369,15 @@ linprocfs_init(PFS_INIT_ARGS) pfs_create_file(dir, "max_map_count", &linprocfs_domax_map_cnt, NULL, NULL, NULL, PFS_RD); + /* /proc/sysvipc/... */ + dir = pfs_create_dir(root, "sysvipc", NULL, NULL, NULL, 0); + pfs_create_file(dir, "msg", &linprocfs_dosysvipc_msg, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(dir, "sem", &linprocfs_dosysvipc_sem, + NULL, NULL, NULL, PFS_RD); + pfs_create_file(dir, "shm", &linprocfs_dosysvipc_shm, + NULL, NULL, NULL, PFS_RD); + return (0); }