[PATCH] /proc/sys/kernel/pointer_size

From: John Levon (levon@movementarian.org)
Date: Wed Jan 08 2003 - 14:59:34 EST


OProfile needs to know the pointer size being used for the kernel,
on platforms with 32-bit userspace and 64-bit kernel. This patch adds
a simple ro sysctl that exports this information as suggested by davem

thanks,
john

diff -X dontdiff -Naur linux-linus/include/linux/sysctl.h linux/include/linux/sysctl.h
--- linux-linus/include/linux/sysctl.h 2003-01-03 02:59:14.000000000 +0000
+++ linux/include/linux/sysctl.h 2003-01-03 03:14:44.000000000 +0000
@@ -129,6 +129,7 @@
         KERN_CADPID=54, /* int: PID of the process to notify on CAD */
         KERN_PIDMAX=55, /* int: PID # limit */
           KERN_CORE_PATTERN=56, /* string: pattern for core-file names */
+ KERN_POINTER_SIZE=57, /* size_t: sizeof(void *) */
 };
 
 
diff -X dontdiff -Naur linux-linus/kernel/sysctl.c linux/kernel/sysctl.c
--- linux-linus/kernel/sysctl.c 2002-12-16 04:09:26.000000000 +0000
+++ linux/kernel/sysctl.c 2002-12-16 04:13:58.000000000 +0000
@@ -56,6 +56,9 @@
 extern int pid_max;
 extern int sysctl_lower_zone_protection;
 
+/* Needed when user-space is 32-bit with 64-bit kernel */
+static int pointer_size = (int)sizeof(void *);
+
 /* this is needed for the proc_dointvec_minmax for [fs_]overflow UID and GID */
 static int maxolduid = 65535;
 static int minolduid;
@@ -180,6 +183,8 @@
          0644, NULL, &proc_dointvec},
         {KERN_CAP_BSET, "cap-bound", &cap_bset, sizeof(kernel_cap_t),
          0600, NULL, &proc_dointvec_bset},
+ {KERN_POINTER_SIZE, "pointer_size", &pointer_size, sizeof(int),
+ 0444, NULL, &proc_dointvec},
 #ifdef CONFIG_BLK_DEV_INITRD
         {KERN_REALROOTDEV, "real-root-dev", &real_root_dev, sizeof(int),
          0644, NULL, &proc_dointvec},
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Wed Jan 15 2003 - 22:00:24 EST