fd7089e44b
Note that the upstream package has been renamed from util-linux-ng back to util-linux. The util-linux-ng is obsolete now. Signed-off-by: Karel Zak <kzak@redhat.com>
49 lines
1.6 KiB
Diff
49 lines
1.6 KiB
Diff
diff -up util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c.kzak util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c
|
|
--- util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c.kzak 2009-03-25 13:19:08.000000000 +0100
|
|
+++ util-linux-ng-2.15.1-rc1/sys-utils/ipcs.c 2009-06-04 15:22:48.000000000 +0200
|
|
@@ -243,6 +243,26 @@ print_perms (int id, struct ipc_perm *ip
|
|
printf(" %-10d\n", ipcp->gid);
|
|
}
|
|
|
|
+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;
|
|
+}
|
|
|
|
void do_shm (char format)
|
|
{
|
|
@@ -266,12 +286,12 @@ void do_shm (char format)
|
|
return;
|
|
/* glibc 2.1.3 and all earlier libc's have ints as fields
|
|
of struct shminfo; glibc 2.1.91 has unsigned long; ach */
|
|
- 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));
|
|
printf (_("max total shared memory (kbytes) = %llu\n"),
|
|
- getpagesize() / 1024 * (unsigned long long) shminfo.shmall);
|
|
+ getpagesize() / 1024 * shminfo_from_proc("shmall", shminfo.shmall));
|
|
printf (_("min seg size (bytes) = %lu\n"),
|
|
(unsigned long) shminfo.shmmin);
|
|
return;
|