PATCH: report NGROUPS_MAX via a sysctl (read-only)
From: Tim Hockin
Date: Thu Feb 19 2004 - 21:41:06 EST
Attached is a simple patch to expose NGROUPS_MAX via sysctl. Nothing fancy,
just a read-only variable. glibc can use this to sysconf() the value
properly, so apps will stop relying on NGROUPS_MAX as a real constant.
Is this the right path? Or should there be a sysconf-specific mechanism?
--
Tim Hockin
Sun Microsystems, Linux Software Engineering
thockin@xxxxxxx
All opinions are my own, not Sun's
===== include/linux/sysctl.h 1.64 vs edited =====
--- 1.64/include/linux/sysctl.h Wed Feb 18 19:43:21 2004
+++ edited/include/linux/sysctl.h Thu Feb 19 17:00:34 2004
@@ -129,6 +129,7 @@
KERN_HPPA_UNALIGNED=59, /* int: hppa unaligned-trap enable */
KERN_PRINTK_RATELIMIT=60, /* int: tune printk ratelimiting */
KERN_PRINTK_RATELIMIT_BURST=61, /* int: tune printk ratelimiting */
+ KERN_NGROUPS_MAX=62, /* int: NGROUPS_MAX */
};
===== kernel/sysctl.c 1.61 vs edited =====
--- 1.61/kernel/sysctl.c Wed Feb 18 19:43:21 2004
+++ edited/kernel/sysctl.c Thu Feb 19 17:05:47 2004
@@ -38,6 +38,7 @@
#include <linux/security.h>
#include <linux/initrd.h>
#include <linux/times.h>
+#include <linux/limits.h>
#include <asm/uaccess.h>
#ifdef CONFIG_ROOT_NFS
@@ -68,6 +69,8 @@
static int maxolduid = 65535;
static int minolduid;
+static int ngroups_max = NGROUPS_MAX;
+
#ifdef CONFIG_KMOD
extern char modprobe_path[];
#endif
@@ -591,6 +594,14 @@
.data = &printk_ratelimit_burst,
.maxlen = sizeof(int),
.mode = 0644,
+ .proc_handler = &proc_dointvec,
+ },
+ {
+ .ctl_name = KERN_NGROUPS_MAX,
+ .procname = "ngroups_max",
+ .data = &ngroups_max,
+ .maxlen = sizeof (int),
+ .mode = 0444,
.proc_handler = &proc_dointvec,
},
{ .ctl_name = 0 }