Back to home page

LXR

 
 

    


0001 /*
0002  *  Copyright (C) 2007 IBM Corporation
0003  *
0004  *  Author: Cedric Le Goater <clg@fr.ibm.com>
0005  *
0006  *  This program is free software; you can redistribute it and/or
0007  *  modify it under the terms of the GNU General Public License as
0008  *  published by the Free Software Foundation, version 2 of the
0009  *  License.
0010  */
0011 
0012 #include <linux/nsproxy.h>
0013 #include <linux/ipc_namespace.h>
0014 #include <linux/sysctl.h>
0015 
0016 #ifdef CONFIG_PROC_SYSCTL
0017 static void *get_mq(struct ctl_table *table)
0018 {
0019     char *which = table->data;
0020     struct ipc_namespace *ipc_ns = current->nsproxy->ipc_ns;
0021     which = (which - (char *)&init_ipc_ns) + (char *)ipc_ns;
0022     return which;
0023 }
0024 
0025 static int proc_mq_dointvec(struct ctl_table *table, int write,
0026                 void __user *buffer, size_t *lenp, loff_t *ppos)
0027 {
0028     struct ctl_table mq_table;
0029     memcpy(&mq_table, table, sizeof(mq_table));
0030     mq_table.data = get_mq(table);
0031 
0032     return proc_dointvec(&mq_table, write, buffer, lenp, ppos);
0033 }
0034 
0035 static int proc_mq_dointvec_minmax(struct ctl_table *table, int write,
0036     void __user *buffer, size_t *lenp, loff_t *ppos)
0037 {
0038     struct ctl_table mq_table;
0039     memcpy(&mq_table, table, sizeof(mq_table));
0040     mq_table.data = get_mq(table);
0041 
0042     return proc_dointvec_minmax(&mq_table, write, buffer,
0043                     lenp, ppos);
0044 }
0045 #else
0046 #define proc_mq_dointvec NULL
0047 #define proc_mq_dointvec_minmax NULL
0048 #endif
0049 
0050 static int msg_max_limit_min = MIN_MSGMAX;
0051 static int msg_max_limit_max = HARD_MSGMAX;
0052 
0053 static int msg_maxsize_limit_min = MIN_MSGSIZEMAX;
0054 static int msg_maxsize_limit_max = HARD_MSGSIZEMAX;
0055 
0056 static struct ctl_table mq_sysctls[] = {
0057     {
0058         .procname   = "queues_max",
0059         .data       = &init_ipc_ns.mq_queues_max,
0060         .maxlen     = sizeof(int),
0061         .mode       = 0644,
0062         .proc_handler   = proc_mq_dointvec,
0063     },
0064     {
0065         .procname   = "msg_max",
0066         .data       = &init_ipc_ns.mq_msg_max,
0067         .maxlen     = sizeof(int),
0068         .mode       = 0644,
0069         .proc_handler   = proc_mq_dointvec_minmax,
0070         .extra1     = &msg_max_limit_min,
0071         .extra2     = &msg_max_limit_max,
0072     },
0073     {
0074         .procname   = "msgsize_max",
0075         .data       = &init_ipc_ns.mq_msgsize_max,
0076         .maxlen     = sizeof(int),
0077         .mode       = 0644,
0078         .proc_handler   = proc_mq_dointvec_minmax,
0079         .extra1     = &msg_maxsize_limit_min,
0080         .extra2     = &msg_maxsize_limit_max,
0081     },
0082     {
0083         .procname   = "msg_default",
0084         .data       = &init_ipc_ns.mq_msg_default,
0085         .maxlen     = sizeof(int),
0086         .mode       = 0644,
0087         .proc_handler   = proc_mq_dointvec_minmax,
0088         .extra1     = &msg_max_limit_min,
0089         .extra2     = &msg_max_limit_max,
0090     },
0091     {
0092         .procname   = "msgsize_default",
0093         .data       = &init_ipc_ns.mq_msgsize_default,
0094         .maxlen     = sizeof(int),
0095         .mode       = 0644,
0096         .proc_handler   = proc_mq_dointvec_minmax,
0097         .extra1     = &msg_maxsize_limit_min,
0098         .extra2     = &msg_maxsize_limit_max,
0099     },
0100     {}
0101 };
0102 
0103 static struct ctl_table mq_sysctl_dir[] = {
0104     {
0105         .procname   = "mqueue",
0106         .mode       = 0555,
0107         .child      = mq_sysctls,
0108     },
0109     {}
0110 };
0111 
0112 static struct ctl_table mq_sysctl_root[] = {
0113     {
0114         .procname   = "fs",
0115         .mode       = 0555,
0116         .child      = mq_sysctl_dir,
0117     },
0118     {}
0119 };
0120 
0121 struct ctl_table_header *mq_register_sysctl_table(void)
0122 {
0123     return register_sysctl_table(mq_sysctl_root);
0124 }