The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=04d3f8e5396edbef0e1d97e9866813163b0c6381

commit 04d3f8e5396edbef0e1d97e9866813163b0c6381
Author:     Ricardo Branco <rbra...@suse.de>
AuthorDate: 2024-05-12 09:49:36 +0000
Commit:     Warner Losh <i...@freebsd.org>
CommitDate: 2024-05-23 19:40:45 +0000

    linprocfs: Add support for proc/sys/fs/mqueue/*
    
    Reviewed by: imp, kib
    Pull Request: https://github.com/freebsd/freebsd-src/pull/1248
---
 sys/compat/linprocfs/linprocfs.c | 107 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 107 insertions(+)

diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index 617eb122291c..c5b6ec9b32c1 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -2220,6 +2220,97 @@ linprocfs_dosysvipc_shm(PFS_FILL_ARGS)
        return (0);
 }
 
+/*
+ * Filler function for proc/sys/fs/mqueue/msg_default
+ */
+static int
+linprocfs_domqueue_msg_default(PFS_FILL_ARGS)
+{
+       int res, error;
+       size_t size = sizeof(res);
+
+       error = kernel_sysctlbyname(curthread, "kern.mqueue.default_maxmsg",
+           &res, &size, NULL, 0, 0, 0);
+       if (error != 0)
+               return (error);
+
+       sbuf_printf(sb, "%d\n", res);
+       return (0);
+}
+
+/*
+ * Filler function for proc/sys/fs/mqueue/msgsize_default
+ */
+static int
+linprocfs_domqueue_msgsize_default(PFS_FILL_ARGS)
+{
+       int res, error;
+       size_t size = sizeof(res);
+
+       error = kernel_sysctlbyname(curthread, "kern.mqueue.default_msgsize",
+           &res, &size, NULL, 0, 0, 0);
+       if (error != 0)
+               return (error);
+
+       sbuf_printf(sb, "%d\n", res);
+       return (0);
+
+}
+
+/*
+ * Filler function for proc/sys/fs/mqueue/msg_max
+ */
+static int
+linprocfs_domqueue_msg_max(PFS_FILL_ARGS)
+{
+       int res, error;
+       size_t size = sizeof(res);
+
+       error = kernel_sysctlbyname(curthread, "kern.mqueue.maxmsg",
+           &res, &size, NULL, 0, 0, 0);
+       if (error != 0)
+               return (error);
+
+       sbuf_printf(sb, "%d\n", res);
+       return (0);
+}
+
+/*
+ * Filler function for proc/sys/fs/mqueue/msgsize_max
+ */
+static int
+linprocfs_domqueue_msgsize_max(PFS_FILL_ARGS)
+{
+       int res, error;
+       size_t size = sizeof(res);
+
+       error = kernel_sysctlbyname(curthread, "kern.mqueue.maxmsgsize",
+           &res, &size, NULL, 0, 0, 0);
+       if (error != 0)
+               return (error);
+
+       sbuf_printf(sb, "%d\n", res);
+       return (0);
+}
+
+/*
+ * Filler function for proc/sys/fs/mqueue/queues_max
+ */
+static int
+linprocfs_domqueue_queues_max(PFS_FILL_ARGS)
+{
+       int res, error;
+       size_t size = sizeof(res);
+
+       error = kernel_sysctlbyname(curthread, "kern.mqueue.maxmq",
+           &res, &size, NULL, 0, 0, 0);
+       if (error != 0)
+               return (error);
+
+       sbuf_printf(sb, "%d\n", res);
+       return (0);
+}
+
 /*
  * Constructor
  */
@@ -2378,6 +2469,22 @@ linprocfs_init(PFS_INIT_ARGS)
        pfs_create_file(dir, "shm", &linprocfs_dosysvipc_shm,
            NULL, NULL, NULL, PFS_RD);
 
+       /* /proc/sys/fs/... */
+       dir = pfs_create_dir(sys, "fs", NULL, NULL, NULL, 0);
+
+       /* /proc/sys/fs/mqueue/... */
+       dir = pfs_create_dir(dir, "mqueue", NULL, NULL, NULL, 0);
+       pfs_create_file(dir, "msg_default", &linprocfs_domqueue_msg_default,
+           NULL, NULL, NULL, PFS_RD);
+       pfs_create_file(dir, "msgsize_default", 
&linprocfs_domqueue_msgsize_default,
+           NULL, NULL, NULL, PFS_RD);
+       pfs_create_file(dir, "msg_max", &linprocfs_domqueue_msg_max,
+           NULL, NULL, NULL, PFS_RD);
+       pfs_create_file(dir, "msgsize_max", &linprocfs_domqueue_msgsize_max,
+           NULL, NULL, NULL, PFS_RD);
+       pfs_create_file(dir, "queues_max", &linprocfs_domqueue_queues_max,
+           NULL, NULL, NULL, PFS_RD);
+
        return (0);
 }
 

Reply via email to