* [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 3:03 [PATCH 1/4] move proc_net_get_sb to a generic fs/super.c helper Serge E. Hallyn
@ 2009-02-24 3:09 ` Serge E. Hallyn
2009-02-24 4:35 ` Alexey Dobriyan
0 siblings, 1 reply; 9+ messages in thread
From: Serge E. Hallyn @ 2009-02-24 3:09 UTC (permalink / raw)
To: Andrew Morton, lkml, Linux Containers
Largely inspired from ipc/ipc_sysctl.c. This patch isolates the mqueue
sysctl stuff in its own file.
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
include/linux/ipc_namespace.h | 14 +++++
init/Kconfig | 6 ++
ipc/Makefile | 1 +
ipc/mq_sysctl.c | 125 +++++++++++++++++++++++++++++++++++++++++
ipc/mqueue.c | 65 +---------------------
5 files changed, 147 insertions(+), 64 deletions(-)
create mode 100644 ipc/mq_sysctl.c
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 3392d50..3bf40e2 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -128,4 +128,18 @@ static inline void put_ipc_ns(struct ipc_namespace *ns)
{
}
#endif
+
+#ifdef CONFIG_POSIX_MQUEUE_SYSCTL
+
+struct ctl_table_header;
+extern struct ctl_table_header *mq_register_sysctl_table(void);
+
+#else /* CONFIG_POSIX_MQUEUE_SYSCTL */
+
+static inline struct ctl_table_header *mq_register_sysctl_table(void)
+{
+ return NULL;
+}
+
+#endif /* CONFIG_POSIX_MQUEUE_SYSCTL */
#endif
diff --git a/init/Kconfig b/init/Kconfig
index 2fd6518..d6a6c08 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -148,6 +148,12 @@ config POSIX_MQUEUE
If unsure, say Y.
+config POSIX_MQUEUE_SYSCTL
+ bool
+ depends on POSIX_MQUEUE
+ depends on SYSCTL
+ default y
+
config BSD_PROCESS_ACCT
bool "BSD Process Accounting"
help
diff --git a/ipc/Makefile b/ipc/Makefile
index 65c3843..4e1955e 100644
--- a/ipc/Makefile
+++ b/ipc/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_SYSVIPC_SYSCTL) += ipc_sysctl.o
obj_mq-$(CONFIG_COMPAT) += compat_mq.o
obj-$(CONFIG_POSIX_MQUEUE) += mqueue.o msgutil.o $(obj_mq-y)
obj-$(CONFIG_IPC_NS) += namespace.o
+obj-$(CONFIG_POSIX_MQUEUE_SYSCTL) += mq_sysctl.o
diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
new file mode 100644
index 0000000..81f01b7
--- /dev/null
+++ b/ipc/mq_sysctl.c
@@ -0,0 +1,125 @@
+/*
+ * Copyright (C) 2007 IBM Corporation
+ *
+ * Author: Cedric Le Goater <clg@fr.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ */
+
+#include <linux/nsproxy.h>
+#include <linux/ipc_namespace.h>
+#include <linux/sysctl.h>
+
+/*
+ * Define the ranges various user-specified maximum values can
+ * be set to.
+ */
+#define MIN_MSGMAX 1 /* min value for msg_max */
+#define MAX_MSGMAX HARD_MSGMAX /* max value for msg_max */
+#define MIN_MSGSIZEMAX 128 /* min value for msgsize_max */
+#define MAX_MSGSIZEMAX (8192*128) /* max value for msgsize_max */
+
+static void *get_mq(ctl_table *table)
+{
+ char *which = table->data;
+ struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
+ which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
+ return which;
+}
+
+#ifdef CONFIG_PROC_FS
+static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ struct ctl_table mq_table;
+ memcpy(&mq_table, table, sizeof(mq_table));
+ mq_table.data = get_mq(table);
+
+ return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
+}
+
+static int proc_mq_dointvec_minmax(ctl_table *table, int write,
+ struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ struct ctl_table mq_table;
+ memcpy(&mq_table, table, sizeof(mq_table));
+ mq_table.data = get_mq(table);
+
+ return proc_dointvec_minmax(&mq_table, write, filp, buffer,
+ lenp, ppos);
+}
+#else /* CONFIG_PROC_FS */
+static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ return -ENOSYS;
+}
+
+static int proc_mq_dointvec_minmax(ctl_table *table, int write,
+ struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ return -ENOSYS;
+}
+#endif /* CONFIG_PROC_FS */
+
+static int msg_max_limit_min = MIN_MSGMAX;
+static int msg_max_limit_max = MAX_MSGMAX;
+
+static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
+static int msg_maxsize_limit_max = MAX_MSGSIZEMAX;
+
+static ctl_table mq_sysctls[] = {
+ {
+ .procname = "queues_max",
+ .data = &init_ipc_ns.mq_queues_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_mq_dointvec,
+ },
+ {
+ .procname = "msg_max",
+ .data = &init_ipc_ns.mq_msg_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_mq_dointvec_minmax,
+ .extra1 = &msg_max_limit_min,
+ .extra2 = &msg_max_limit_max,
+ },
+ {
+ .procname = "msgsize_max",
+ .data = &init_ipc_ns.mq_msgsize_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = &proc_mq_dointvec_minmax,
+ .extra1 = &msg_maxsize_limit_min,
+ .extra2 = &msg_maxsize_limit_max,
+ },
+ { .ctl_name = 0 }
+};
+
+static ctl_table mq_sysctl_dir[] = {
+ {
+ .procname = "mqueue",
+ .mode = 0555,
+ .child = mq_sysctls,
+ },
+ { .ctl_name = 0 }
+};
+
+static ctl_table mq_sysctl_root[] = {
+ {
+ .ctl_name = CTL_FS,
+ .procname = "fs",
+ .mode = 0555,
+ .child = mq_sysctl_dir,
+ },
+ { .ctl_name = 0 }
+};
+
+struct ctl_table_header *mq_register_sysctl_table(void)
+{
+ return register_sysctl_table(mq_sysctl_root);
+}
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 1b169b7..61ff295 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -47,15 +47,6 @@
#define STATE_PENDING 1
#define STATE_READY 2
-/*
- * Define the ranges various user-specified maximum values can
- * be set to.
- */
-#define MIN_MSGMAX 1 /* min value for msg_max */
-#define MAX_MSGMAX HARD_MSGMAX /* max value for msg_max */
-#define MIN_MSGSIZEMAX 128 /* min value for msgsize_max */
-#define MAX_MSGSIZEMAX (8192*128) /* max value for msgsize_max */
-
struct ext_wait_queue { /* queue of sleeping tasks */
struct task_struct *task;
struct list_head list;
@@ -1269,60 +1260,6 @@ void mq_put_mnt(struct ipc_namespace *ns)
mntput(ns->mq_mnt);
}
-static int msg_max_limit_min = MIN_MSGMAX;
-static int msg_max_limit_max = MAX_MSGMAX;
-
-static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
-static int msg_maxsize_limit_max = MAX_MSGSIZEMAX;
-
-static ctl_table mq_sysctls[] = {
- {
- .procname = "queues_max",
- .data = &init_ipc_ns.mq_queues_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "msg_max",
- .data = &init_ipc_ns.mq_msg_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec_minmax,
- .extra1 = &msg_max_limit_min,
- .extra2 = &msg_max_limit_max,
- },
- {
- .procname = "msgsize_max",
- .data = &init_ipc_ns.mq_msgsize_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec_minmax,
- .extra1 = &msg_maxsize_limit_min,
- .extra2 = &msg_maxsize_limit_max,
- },
- { .ctl_name = 0 }
-};
-
-static ctl_table mq_sysctl_dir[] = {
- {
- .procname = "mqueue",
- .mode = 0555,
- .child = mq_sysctls,
- },
- { .ctl_name = 0 }
-};
-
-static ctl_table mq_sysctl_root[] = {
- {
- .ctl_name = CTL_FS,
- .procname = "fs",
- .mode = 0555,
- .child = mq_sysctl_dir,
- },
- { .ctl_name = 0 }
-};
-
static int __init init_mqueue_fs(void)
{
int error;
@@ -1334,7 +1271,7 @@ static int __init init_mqueue_fs(void)
return -ENOMEM;
/* ignore failues - they are not fatal */
- mq_sysctl_table = register_sysctl_table(mq_sysctl_root);
+ mq_sysctl_table = mq_register_sysctl_table();
error = register_filesystem(&mqueue_fs_type);
if (error)
--
1.5.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 3:09 ` [PATCH 4/4] mqueue namespace: adapt sysctl Serge E. Hallyn
@ 2009-02-24 4:35 ` Alexey Dobriyan
2009-02-24 8:25 ` Cedric Le Goater
0 siblings, 1 reply; 9+ messages in thread
From: Alexey Dobriyan @ 2009-02-24 4:35 UTC (permalink / raw)
To: Serge E. Hallyn; +Cc: Andrew Morton, lkml, Linux Containers
On Mon, Feb 23, 2009 at 09:09:33PM -0600, Serge E. Hallyn wrote:
> +#ifdef CONFIG_PROC_FS
> +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
> + void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + struct ctl_table mq_table;
> + memcpy(&mq_table, table, sizeof(mq_table));
> + mq_table.data = get_mq(table);
> +
> + return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
> +}
> +
> +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
> + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + struct ctl_table mq_table;
> + memcpy(&mq_table, table, sizeof(mq_table));
> + mq_table.data = get_mq(table);
> +
> + return proc_dointvec_minmax(&mq_table, write, filp, buffer,
> + lenp, ppos);
> +}
> +#else /* CONFIG_PROC_FS */
> +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
> + void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + return -ENOSYS;
> +}
> +
> +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
> + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + return -ENOSYS;
> +}
> +#endif /* CONFIG_PROC_FS */
These should be under CONFIG_PROC_SYSCTL and one should define them to
NULL otherwise.
> +static ctl_table mq_sysctls[] = {
> + {
> + .procname = "queues_max",
> + .data = &init_ipc_ns.mq_queues_max,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = &proc_mq_dointvec,
^
No &, please. I'm removing them.
> + },
> + {
> + .procname = "msg_max",
> + .data = &init_ipc_ns.mq_msg_max,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = &proc_mq_dointvec_minmax,
> + .extra1 = &msg_max_limit_min,
> + .extra2 = &msg_max_limit_max,
> + },
> + {
> + .procname = "msgsize_max",
> + .data = &init_ipc_ns.mq_msgsize_max,
> + .maxlen = sizeof(int),
> + .mode = 0644,
> + .proc_handler = &proc_mq_dointvec_minmax,
> + .extra1 = &msg_maxsize_limit_min,
> + .extra2 = &msg_maxsize_limit_max,
> + },
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 4:35 ` Alexey Dobriyan
@ 2009-02-24 8:25 ` Cedric Le Goater
0 siblings, 0 replies; 9+ messages in thread
From: Cedric Le Goater @ 2009-02-24 8:25 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: Serge E. Hallyn, Linux Containers, Andrew Morton, lkml
Alexey Dobriyan wrote:
> On Mon, Feb 23, 2009 at 09:09:33PM -0600, Serge E. Hallyn wrote:
>> +#ifdef CONFIG_PROC_FS
>> +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
>> + void __user *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> + struct ctl_table mq_table;
>> + memcpy(&mq_table, table, sizeof(mq_table));
>> + mq_table.data = get_mq(table);
>> +
>> + return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
>> +}
>> +
>> +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
>> + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> + struct ctl_table mq_table;
>> + memcpy(&mq_table, table, sizeof(mq_table));
>> + mq_table.data = get_mq(table);
>> +
>> + return proc_dointvec_minmax(&mq_table, write, filp, buffer,
>> + lenp, ppos);
>> +}
>> +#else /* CONFIG_PROC_FS */
>> +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
>> + void __user *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> + return -ENOSYS;
>> +}
>> +
>> +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
>> + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
>> +{
>> + return -ENOSYS;
>> +}
>> +#endif /* CONFIG_PROC_FS */
>
> These should be under CONFIG_PROC_SYSCTL and one should define them to
> NULL otherwise.
ipc_sysctl.c and utsname_sysctl.c need to fix the CONFIG_PROC_FS #ifdef.
C.
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 4/4] mqueue namespace: adapt sysctl
@ 2009-02-24 22:02 Serge E. Hallyn
2009-02-24 22:16 ` Andrew Morton
0 siblings, 1 reply; 9+ messages in thread
From: Serge E. Hallyn @ 2009-02-24 22:02 UTC (permalink / raw)
To: Andrew Morton, Alexey Dobriyan, Cedric Le Goater; +Cc: lkml, Linux Containers
Largely inspired from ipc/ipc_sysctl.c. This patch isolates the mqueue
sysctl stuff in its own file.
Changelog:
Feb 24: comments from Alexey Dobriyan:
1. put proc handlers under CONFIG_PROC_SYSCTL and
make them NULL otherwise.
2. remove & from proc_handler when assigned to
ctl_table.
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Nadia Derbey <Nadia.Derbey@bull.net>
Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>
---
include/linux/ipc_namespace.h | 14 +++++
init/Kconfig | 6 ++
ipc/Makefile | 1 +
ipc/mq_sysctl.c | 116 +++++++++++++++++++++++++++++++++++++++++
ipc/mqueue.c | 65 +----------------------
5 files changed, 138 insertions(+), 64 deletions(-)
create mode 100644 ipc/mq_sysctl.c
diff --git a/include/linux/ipc_namespace.h b/include/linux/ipc_namespace.h
index 3392d50..3bf40e2 100644
--- a/include/linux/ipc_namespace.h
+++ b/include/linux/ipc_namespace.h
@@ -128,4 +128,18 @@ static inline void put_ipc_ns(struct ipc_namespace *ns)
{
}
#endif
+
+#ifdef CONFIG_POSIX_MQUEUE_SYSCTL
+
+struct ctl_table_header;
+extern struct ctl_table_header *mq_register_sysctl_table(void);
+
+#else /* CONFIG_POSIX_MQUEUE_SYSCTL */
+
+static inline struct ctl_table_header *mq_register_sysctl_table(void)
+{
+ return NULL;
+}
+
+#endif /* CONFIG_POSIX_MQUEUE_SYSCTL */
#endif
diff --git a/init/Kconfig b/init/Kconfig
index 53afa38..ee70d25 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -148,6 +148,12 @@ config POSIX_MQUEUE
If unsure, say Y.
+config POSIX_MQUEUE_SYSCTL
+ bool
+ depends on POSIX_MQUEUE
+ depends on SYSCTL
+ default y
+
config BSD_PROCESS_ACCT
bool "BSD Process Accounting"
help
diff --git a/ipc/Makefile b/ipc/Makefile
index 65c3843..4e1955e 100644
--- a/ipc/Makefile
+++ b/ipc/Makefile
@@ -8,4 +8,5 @@ obj-$(CONFIG_SYSVIPC_SYSCTL) += ipc_sysctl.o
obj_mq-$(CONFIG_COMPAT) += compat_mq.o
obj-$(CONFIG_POSIX_MQUEUE) += mqueue.o msgutil.o $(obj_mq-y)
obj-$(CONFIG_IPC_NS) += namespace.o
+obj-$(CONFIG_POSIX_MQUEUE_SYSCTL) += mq_sysctl.o
diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
new file mode 100644
index 0000000..b542a1d
--- /dev/null
+++ b/ipc/mq_sysctl.c
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2007 IBM Corporation
+ *
+ * Author: Cedric Le Goater <clg@fr.ibm.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation, version 2 of the
+ * License.
+ */
+
+#include <linux/nsproxy.h>
+#include <linux/ipc_namespace.h>
+#include <linux/sysctl.h>
+
+/*
+ * Define the ranges various user-specified maximum values can
+ * be set to.
+ */
+#define MIN_MSGMAX 1 /* min value for msg_max */
+#define MAX_MSGMAX HARD_MSGMAX /* max value for msg_max */
+#define MIN_MSGSIZEMAX 128 /* min value for msgsize_max */
+#define MAX_MSGSIZEMAX (8192*128) /* max value for msgsize_max */
+
+static void *get_mq(ctl_table *table)
+{
+ char *which = table->data;
+ struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
+ which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
+ return which;
+}
+
+#ifdef CONFIG_PROC_SYSCTL
+static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
+ void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ struct ctl_table mq_table;
+ memcpy(&mq_table, table, sizeof(mq_table));
+ mq_table.data = get_mq(table);
+
+ return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
+}
+
+static int proc_mq_dointvec_minmax(ctl_table *table, int write,
+ struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
+{
+ struct ctl_table mq_table;
+ memcpy(&mq_table, table, sizeof(mq_table));
+ mq_table.data = get_mq(table);
+
+ return proc_dointvec_minmax(&mq_table, write, filp, buffer,
+ lenp, ppos);
+}
+#else
+proc_handler *proc_mq_dointvec = NULL;
+proc_handler *proc_mq_dointvec_minmax = NULL;
+#endif
+
+static int msg_max_limit_min = MIN_MSGMAX;
+static int msg_max_limit_max = MAX_MSGMAX;
+
+static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
+static int msg_maxsize_limit_max = MAX_MSGSIZEMAX;
+
+static ctl_table mq_sysctls[] = {
+ {
+ .procname = "queues_max",
+ .data = &init_ipc_ns.mq_queues_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_mq_dointvec,
+ },
+ {
+ .procname = "msg_max",
+ .data = &init_ipc_ns.mq_msg_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_mq_dointvec_minmax,
+ .extra1 = &msg_max_limit_min,
+ .extra2 = &msg_max_limit_max,
+ },
+ {
+ .procname = "msgsize_max",
+ .data = &init_ipc_ns.mq_msgsize_max,
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_mq_dointvec_minmax,
+ .extra1 = &msg_maxsize_limit_min,
+ .extra2 = &msg_maxsize_limit_max,
+ },
+ { .ctl_name = 0 }
+};
+
+static ctl_table mq_sysctl_dir[] = {
+ {
+ .procname = "mqueue",
+ .mode = 0555,
+ .child = mq_sysctls,
+ },
+ { .ctl_name = 0 }
+};
+
+static ctl_table mq_sysctl_root[] = {
+ {
+ .ctl_name = CTL_FS,
+ .procname = "fs",
+ .mode = 0555,
+ .child = mq_sysctl_dir,
+ },
+ { .ctl_name = 0 }
+};
+
+struct ctl_table_header *mq_register_sysctl_table(void)
+{
+ return register_sysctl_table(mq_sysctl_root);
+}
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index 3e016e9..7f10fde 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -47,15 +47,6 @@
#define STATE_PENDING 1
#define STATE_READY 2
-/*
- * Define the ranges various user-specified maximum values can
- * be set to.
- */
-#define MIN_MSGMAX 1 /* min value for msg_max */
-#define MAX_MSGMAX HARD_MSGMAX /* max value for msg_max */
-#define MIN_MSGSIZEMAX 128 /* min value for msgsize_max */
-#define MAX_MSGSIZEMAX (8192*128) /* max value for msgsize_max */
-
struct ext_wait_queue { /* queue of sleeping tasks */
struct task_struct *task;
struct list_head list;
@@ -1271,60 +1262,6 @@ void mq_put_mnt(struct ipc_namespace *ns)
mntput(ns->mq_mnt);
}
-static int msg_max_limit_min = MIN_MSGMAX;
-static int msg_max_limit_max = MAX_MSGMAX;
-
-static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
-static int msg_maxsize_limit_max = MAX_MSGSIZEMAX;
-
-static ctl_table mq_sysctls[] = {
- {
- .procname = "queues_max",
- .data = &init_ipc_ns.mq_queues_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "msg_max",
- .data = &init_ipc_ns.mq_msg_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec_minmax,
- .extra1 = &msg_max_limit_min,
- .extra2 = &msg_max_limit_max,
- },
- {
- .procname = "msgsize_max",
- .data = &init_ipc_ns.mq_msgsize_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec_minmax,
- .extra1 = &msg_maxsize_limit_min,
- .extra2 = &msg_maxsize_limit_max,
- },
- { .ctl_name = 0 }
-};
-
-static ctl_table mq_sysctl_dir[] = {
- {
- .procname = "mqueue",
- .mode = 0555,
- .child = mq_sysctls,
- },
- { .ctl_name = 0 }
-};
-
-static ctl_table mq_sysctl_root[] = {
- {
- .ctl_name = CTL_FS,
- .procname = "fs",
- .mode = 0555,
- .child = mq_sysctl_dir,
- },
- { .ctl_name = 0 }
-};
-
static int __init init_mqueue_fs(void)
{
int error;
@@ -1336,7 +1273,7 @@ static int __init init_mqueue_fs(void)
return -ENOMEM;
/* ignore failues - they are not fatal */
- mq_sysctl_table = register_sysctl_table(mq_sysctl_root);
+ mq_sysctl_table = mq_register_sysctl_table();
error = register_filesystem(&mqueue_fs_type);
if (error)
--
1.5.4.3
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 22:02 [PATCH 4/4] mqueue namespace: adapt sysctl Serge E. Hallyn
@ 2009-02-24 22:16 ` Andrew Morton
2009-02-24 22:32 ` Serge E. Hallyn
2009-02-24 22:32 ` Alexey Dobriyan
0 siblings, 2 replies; 9+ messages in thread
From: Andrew Morton @ 2009-02-24 22:16 UTC (permalink / raw)
To: Serge E. Hallyn; +Cc: adobriyan, clg, linux-kernel, containers
On Tue, 24 Feb 2009 16:02:56 -0600
"Serge E. Hallyn" <serue@us.ibm.com> wrote:
> +#ifdef CONFIG_PROC_SYSCTL
> +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
> + void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + struct ctl_table mq_table;
> + memcpy(&mq_table, table, sizeof(mq_table));
> + mq_table.data = get_mq(table);
> +
> + return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
> +}
> +
> +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
> + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
> +{
> + struct ctl_table mq_table;
> + memcpy(&mq_table, table, sizeof(mq_table));
> + mq_table.data = get_mq(table);
> +
> + return proc_dointvec_minmax(&mq_table, write, filp, buffer,
> + lenp, ppos);
> +}
> +#else
> +proc_handler *proc_mq_dointvec = NULL;
> +proc_handler *proc_mq_dointvec_minmax = NULL;
> +#endif
looks odd. Was this
--- a/ipc/mq_sysctl.c~mqueue-namespace-adapt-sysctl-update-fix
+++ a/ipc/mq_sysctl.c
@@ -52,8 +52,8 @@ static int proc_mq_dointvec_minmax(ctl_t
lenp, ppos);
}
#else
-proc_handler *proc_mq_dointvec = NULL;
-proc_handler *proc_mq_dointvec_minmax = NULL;
+#define proc_mq_dointvec NULL
+#define proc_mq_dointvec_minmax NULL
#endif
static int msg_max_limit_min = MIN_MSGMAX;
_
intended?
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 22:16 ` Andrew Morton
@ 2009-02-24 22:32 ` Serge E. Hallyn
2009-02-24 22:32 ` Alexey Dobriyan
1 sibling, 0 replies; 9+ messages in thread
From: Serge E. Hallyn @ 2009-02-24 22:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: adobriyan, clg, linux-kernel, containers
Quoting Andrew Morton (akpm@linux-foundation.org):
> On Tue, 24 Feb 2009 16:02:56 -0600
> "Serge E. Hallyn" <serue@us.ibm.com> wrote:
>
> > +#ifdef CONFIG_PROC_SYSCTL
> > +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
> > + void __user *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + struct ctl_table mq_table;
> > + memcpy(&mq_table, table, sizeof(mq_table));
> > + mq_table.data = get_mq(table);
> > +
> > + return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
> > +}
> > +
> > +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
> > + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + struct ctl_table mq_table;
> > + memcpy(&mq_table, table, sizeof(mq_table));
> > + mq_table.data = get_mq(table);
> > +
> > + return proc_dointvec_minmax(&mq_table, write, filp, buffer,
> > + lenp, ppos);
> > +}
> > +#else
> > +proc_handler *proc_mq_dointvec = NULL;
> > +proc_handler *proc_mq_dointvec_minmax = NULL;
> > +#endif
>
> looks odd. Was this
>
> --- a/ipc/mq_sysctl.c~mqueue-namespace-adapt-sysctl-update-fix
> +++ a/ipc/mq_sysctl.c
> @@ -52,8 +52,8 @@ static int proc_mq_dointvec_minmax(ctl_t
> lenp, ppos);
> }
> #else
> -proc_handler *proc_mq_dointvec = NULL;
> -proc_handler *proc_mq_dointvec_minmax = NULL;
> +#define proc_mq_dointvec NULL
> +#define proc_mq_dointvec_minmax NULL
> #endif
>
> static int msg_max_limit_min = MIN_MSGMAX;
> _
>
> intended?
It just seemed more in line with the idea of ensuring type
safety... Of course the #defines will work and are how the
others (at least ipc and utsname) do it, but this seemed
a touch better. Of course I'll change it if that's the
preference.
thanks,
-serge
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 22:16 ` Andrew Morton
2009-02-24 22:32 ` Serge E. Hallyn
@ 2009-02-24 22:32 ` Alexey Dobriyan
2009-02-24 22:48 ` Andrew Morton
1 sibling, 1 reply; 9+ messages in thread
From: Alexey Dobriyan @ 2009-02-24 22:32 UTC (permalink / raw)
To: Andrew Morton; +Cc: Serge E. Hallyn, clg, linux-kernel, containers
On Tue, Feb 24, 2009 at 02:16:51PM -0800, Andrew Morton wrote:
> On Tue, 24 Feb 2009 16:02:56 -0600
> "Serge E. Hallyn" <serue@us.ibm.com> wrote:
>
> > +#ifdef CONFIG_PROC_SYSCTL
> > +static int proc_mq_dointvec(ctl_table *table, int write, struct file *filp,
> > + void __user *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + struct ctl_table mq_table;
> > + memcpy(&mq_table, table, sizeof(mq_table));
> > + mq_table.data = get_mq(table);
> > +
> > + return proc_dointvec(&mq_table, write, filp, buffer, lenp, ppos);
> > +}
> > +
> > +static int proc_mq_dointvec_minmax(ctl_table *table, int write,
> > + struct file *filp, void __user *buffer, size_t *lenp, loff_t *ppos)
> > +{
> > + struct ctl_table mq_table;
> > + memcpy(&mq_table, table, sizeof(mq_table));
> > + mq_table.data = get_mq(table);
> > +
> > + return proc_dointvec_minmax(&mq_table, write, filp, buffer,
> > + lenp, ppos);
> > +}
> > +#else
> > +proc_handler *proc_mq_dointvec = NULL;
> > +proc_handler *proc_mq_dointvec_minmax = NULL;
> > +#endif
>
> looks odd. Was this
>
> --- a/ipc/mq_sysctl.c~mqueue-namespace-adapt-sysctl-update-fix
> +++ a/ipc/mq_sysctl.c
> @@ -52,8 +52,8 @@ static int proc_mq_dointvec_minmax(ctl_t
> lenp, ppos);
> }
> #else
> -proc_handler *proc_mq_dointvec = NULL;
> -proc_handler *proc_mq_dointvec_minmax = NULL;
> +#define proc_mq_dointvec NULL
> +#define proc_mq_dointvec_minmax NULL
> #endif
I hope, not.
"#define foo NULL" is the least intrusive thing.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 22:32 ` Alexey Dobriyan
@ 2009-02-24 22:48 ` Andrew Morton
2009-02-24 23:23 ` Serge E. Hallyn
0 siblings, 1 reply; 9+ messages in thread
From: Andrew Morton @ 2009-02-24 22:48 UTC (permalink / raw)
To: Alexey Dobriyan; +Cc: serue, clg, linux-kernel, containers
On Wed, 25 Feb 2009 01:32:45 +0300
Alexey Dobriyan <adobriyan@gmail.com> wrote:
> > > +proc_handler *proc_mq_dointvec = NULL;
> > > +proc_handler *proc_mq_dointvec_minmax = NULL;
> > > +#endif
> >
> > looks odd. Was this
> >
> > --- a/ipc/mq_sysctl.c~mqueue-namespace-adapt-sysctl-update-fix
> > +++ a/ipc/mq_sysctl.c
> > @@ -52,8 +52,8 @@ static int proc_mq_dointvec_minmax(ctl_t
> > lenp, ppos);
> > }
> > #else
> > -proc_handler *proc_mq_dointvec = NULL;
> > -proc_handler *proc_mq_dointvec_minmax = NULL;
> > +#define proc_mq_dointvec NULL
> > +#define proc_mq_dointvec_minmax NULL
> > #endif
>
> I hope, not.
>
> "#define foo NULL" is the least intrusive thing.
well the original code would have spat a warning at compile time
then tried to execute code from BSS at runtime, methinks.
But I can't be assed working out how to disable CONFIG_SYSCTL to
test that. Gawd I hate `select'.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 4/4] mqueue namespace: adapt sysctl
2009-02-24 22:48 ` Andrew Morton
@ 2009-02-24 23:23 ` Serge E. Hallyn
0 siblings, 0 replies; 9+ messages in thread
From: Serge E. Hallyn @ 2009-02-24 23:23 UTC (permalink / raw)
To: Andrew Morton; +Cc: Alexey Dobriyan, clg, linux-kernel, containers
Quoting Andrew Morton (akpm@linux-foundation.org):
> On Wed, 25 Feb 2009 01:32:45 +0300
> Alexey Dobriyan <adobriyan@gmail.com> wrote:
>
> > > > +proc_handler *proc_mq_dointvec = NULL;
> > > > +proc_handler *proc_mq_dointvec_minmax = NULL;
> > > > +#endif
> > >
> > > looks odd. Was this
> > >
> > > --- a/ipc/mq_sysctl.c~mqueue-namespace-adapt-sysctl-update-fix
> > > +++ a/ipc/mq_sysctl.c
> > > @@ -52,8 +52,8 @@ static int proc_mq_dointvec_minmax(ctl_t
> > > lenp, ppos);
> > > }
> > > #else
> > > -proc_handler *proc_mq_dointvec = NULL;
> > > -proc_handler *proc_mq_dointvec_minmax = NULL;
> > > +#define proc_mq_dointvec NULL
> > > +#define proc_mq_dointvec_minmax NULL
> > > #endif
> >
> > I hope, not.
> >
> > "#define foo NULL" is the least intrusive thing.
>
> well the original code would have spat a warning at compile time
> then tried to execute code from BSS at runtime, methinks.
>
> But I can't be assed working out how to disable CONFIG_SYSCTL to
> test that. Gawd I hate `select'.
Yeah that's a pain... but so I tested it with the below userspace
program before sending the patch and the 'if (myhandler)' check (which
is analogous to the check in proc_sys_call_handler) worked as expected.
thanks,
-serge
#include <stdio.h>
typedef int proc_handler (int a, int b);
#ifdef FOO
int myhandler(int a, int b) {
printf("a was %d b was %d\n", a, b);
}
#else
proc_handler *myhandler = NULL;
#endif
int main()
{
if (myhandler)
myhandler(1, 2);
}
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2009-02-24 23:23 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-24 22:02 [PATCH 4/4] mqueue namespace: adapt sysctl Serge E. Hallyn
2009-02-24 22:16 ` Andrew Morton
2009-02-24 22:32 ` Serge E. Hallyn
2009-02-24 22:32 ` Alexey Dobriyan
2009-02-24 22:48 ` Andrew Morton
2009-02-24 23:23 ` Serge E. Hallyn
-- strict thread matches above, loose matches on Subject: below --
2009-02-24 3:03 [PATCH 1/4] move proc_net_get_sb to a generic fs/super.c helper Serge E. Hallyn
2009-02-24 3:09 ` [PATCH 4/4] mqueue namespace: adapt sysctl Serge E. Hallyn
2009-02-24 4:35 ` Alexey Dobriyan
2009-02-24 8:25 ` Cedric Le Goater
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox