patch-2.2.11 linux/kernel/sysctl.c
Next file: linux/lib/string.c
Previous file: linux/kernel/signal.c
Back to the patch index
Back to the overall index
- Lines: 141
- Date:
Mon Aug 9 12:05:13 1999
- Orig file:
v2.2.10/linux/kernel/sysctl.c
- Orig date:
Sat Feb 6 12:22:24 1999
diff -u --recursive --new-file v2.2.10/linux/kernel/sysctl.c linux/kernel/sysctl.c
@@ -18,9 +18,10 @@
#include <linux/proc_fs.h>
#include <linux/ctype.h>
#include <linux/utsname.h>
-#include <linux/swapctl.h>
+#include <linux/capability.h>
#include <linux/smp_lock.h>
#include <linux/init.h>
+#include <linux/sysrq.h>
#include <asm/uaccess.h>
@@ -164,6 +165,8 @@
0644, NULL, &proc_doutsstring, &sysctl_string},
{KERN_PANIC, "panic", &panic_timeout, sizeof(int),
0644, NULL, &proc_dointvec},
+ {KERN_CAP_BSET, "cap-bound", &cap_bset, sizeof(kernel_cap_t),
+ 0600, NULL, &proc_dointvec_bset},
#ifdef CONFIG_BLK_DEV_INITRD
{KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int),
0644, NULL, &proc_dointvec},
@@ -212,6 +215,10 @@
{KERN_SHMMAX, "shmmax", &shmmax, sizeof (int),
0644, NULL, &proc_dointvec},
#endif
+#ifdef CONFIG_MAGIC_SYSRQ
+ {KERN_SYSRQ, "sysrq", &sysrq_enabled, sizeof (int),
+ 0644, NULL, &proc_dointvec},
+#endif
{0}
};
@@ -563,7 +570,6 @@
continue;
}
- /* Don't unregoster proc entries that are still being used.. */
if (de->count)
continue;
@@ -684,8 +690,13 @@
return r;
}
+#define OP_SET 0
+#define OP_AND 1
+#define OP_OR 2
+#define OP_MAX 3
+#define OP_MIN 4
static int do_proc_dointvec(ctl_table *table, int write, struct file *filp,
- void *buffer, size_t *lenp, int conv)
+ void *buffer, size_t *lenp, int conv, int op)
{
int *i, vleft, first=1, len, left, neg, val;
#define TMPBUFLEN 20
@@ -736,7 +747,17 @@
val = -val;
buffer += len;
left -= len;
- *i = val;
+ switch(op) {
+ case OP_SET: *i = val; break;
+ case OP_AND: *i &= val; break;
+ case OP_OR: *i |= val; break;
+ case OP_MAX: if(*i < val)
+ *i = val;
+ break;
+ case OP_MIN: if(*i > val)
+ *i = val;
+ break;
+ }
} else {
p = buf;
if (!first)
@@ -778,9 +799,21 @@
int proc_dointvec(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp)
{
- return do_proc_dointvec(table,write,filp,buffer,lenp,1);
+ return do_proc_dointvec(table,write,filp,buffer,lenp,1,OP_SET);
+}
+
+/*
+ * init may raise the set.
+ */
+
+int proc_dointvec_bset(ctl_table *table, int write, struct file *filp,
+ void *buffer, size_t *lenp)
+{
+ return do_proc_dointvec(table,write,filp,buffer,lenp,1,
+ (current->pid == 1) ? OP_SET : OP_AND);
}
+
int proc_dointvec_minmax(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp)
{
@@ -883,7 +916,7 @@
int proc_dointvec_jiffies(ctl_table *table, int write, struct file *filp,
void *buffer, size_t *lenp)
{
- return do_proc_dointvec(table,write,filp,buffer,lenp,HZ);
+ return do_proc_dointvec(table,write,filp,buffer,lenp,HZ,OP_SET);
}
#else /* CONFIG_PROC_FS */
@@ -1000,6 +1033,34 @@
}
}
return 0;
+}
+
+/* Strategy function to convert jiffies to seconds */
+int sysctl_jiffies(ctl_table *table, int *name, int nlen,
+ void *oldval, size_t *oldlenp,
+ void *newval, size_t newlen, void **context)
+{
+ if (oldval) {
+ size_t olen;
+ if (oldlenp) {
+ if (get_user(olen, oldlenp))
+ return -EFAULT;
+ if (olen!=sizeof(int))
+ return -EINVAL;
+ }
+ if (put_user(*(int *)(table->data) / HZ, (int *)oldval) ||
+ (oldlenp && put_user(sizeof(int),oldlenp)))
+ return -EFAULT;
+ }
+ if (newval && newlen) {
+ int new;
+ if (newlen != sizeof(int))
+ return -EINVAL;
+ if (get_user(new, (int *)newval))
+ return -EFAULT;
+ *(int *)(table->data) = new*HZ;
+ }
+ return 1;
}
int do_string (
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)