2012-02-07 13:12:06 +00:00
|
|
|
diff -up util-linux-2.21-rc1/sys-utils/ipcs.c.kzak util-linux-2.21-rc1/sys-utils/ipcs.c
|
|
|
|
--- util-linux-2.21-rc1/sys-utils/ipcs.c.kzak 2012-01-19 13:31:26.328579820 +0100
|
|
|
|
+++ util-linux-2.21-rc1/sys-utils/ipcs.c 2012-01-19 13:33:40.968066006 +0100
|
|
|
|
@@ -262,6 +262,27 @@ static void print_perms (int id, struct
|
|
|
|
printf(" %-10u\n", ipcp->gid);
|
2011-01-19 08:56:35 +00:00
|
|
|
}
|
2012-02-07 13:12:06 +00:00
|
|
|
|
2011-01-19 08:56:35 +00:00
|
|
|
+static unsigned long long
|
|
|
|
+shminfo_from_proc(const char *name, unsigned long def)
|
|
|
|
+{
|
|
|
|
+ char path[256];
|
|
|
|
+ char buf[64];
|
|
|
|
+ FILE *f;
|
|
|
|
+ unsigned long long res = def;
|
|
|
|
+
|
|
|
|
+ if (!name)
|
|
|
|
+ return res;
|
|
|
|
+
|
|
|
|
+ snprintf(path, sizeof(path), "/proc/sys/kernel/%s", name);
|
|
|
|
+
|
|
|
|
+ if (!(f = fopen(path, "r")))
|
|
|
|
+ return res;
|
|
|
|
+ if (fgets(buf, sizeof(buf), f))
|
|
|
|
+ res = atoll(buf);
|
|
|
|
+ fclose(f);
|
|
|
|
+ return res;
|
|
|
|
+}
|
2011-08-17 09:34:12 +00:00
|
|
|
+
|
2011-01-19 08:56:35 +00:00
|
|
|
void do_shm (char format)
|
|
|
|
{
|
2012-02-07 13:12:06 +00:00
|
|
|
int maxid, shmid, id;
|
|
|
|
@@ -286,12 +307,12 @@ void do_shm (char format)
|
|
|
|
* glibc 2.1.3 and all earlier libc's have ints as fields of
|
|
|
|
* struct shminfo; glibc 2.1.91 has unsigned long; ach
|
|
|
|
*/
|
2011-01-19 08:56:35 +00:00
|
|
|
- printf (_("max number of segments = %lu\n"),
|
|
|
|
- (unsigned long) shminfo.shmmni);
|
|
|
|
- printf (_("max seg size (kbytes) = %lu\n"),
|
|
|
|
- (unsigned long) (shminfo.shmmax >> 10));
|
|
|
|
+ printf (_("max number of segments = %llu\n"),
|
|
|
|
+ shminfo_from_proc("shmmni", shminfo.shmmni));
|
|
|
|
+ printf (_("max seg size (kbytes) = %llu\n"),
|
|
|
|
+ (shminfo_from_proc("shmmax", shminfo.shmmax) >> 10));
|
2012-02-07 13:12:06 +00:00
|
|
|
printf (_("max total shared memory (kbytes) = %llu\n"),
|
2011-01-19 08:56:35 +00:00
|
|
|
- getpagesize() / 1024 * (unsigned long long) shminfo.shmall);
|
|
|
|
+ getpagesize() / 1024 * shminfo_from_proc("shmall", shminfo.shmall));
|
2012-02-07 13:12:06 +00:00
|
|
|
printf (_("min seg size (bytes) = %lu\n"),
|
|
|
|
(unsigned long) shminfo.shmmin);
|
|
|
|
return;
|