]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
ipcs: --shmems, upward/backward compatibility
authorRuediger Meier <ruediger.meier@ga-group.nl>
Fri, 18 Mar 2016 11:49:18 +0000 (12:49 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 18 Mar 2016 14:38:06 +0000 (15:38 +0100)
Re-add backward compatibility which got lost in 058e8154.
Initializing unknown struct members to 0xdead is similar to
the fallback.

For upward compatibility ignore columns > 16 but not the whole
line (in case the kernel would add more columns in future).

Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
sys-utils/ipcutils.c

index c763cde696f02a914466eb0c965f08a5e0e70205..349e8550ed1a3f8d4a41581fbf11c2c7a117b36c 100644 (file)
@@ -113,6 +113,9 @@ int ipc_shm_get_info(int id, struct shm_data **shmds)
        while (fgetc(f) != '\n');               /* skip header */
 
        while (fgets(buf, sizeof(buf), f) != NULL) {
+               /* scan for the first 14-16 columns (e.g. Linux 2.6.32 has 14) */
+               p->shm_rss = 0xdead;
+               p->shm_swp = 0xdead;
                if (sscanf(buf,
                          "%d %d  %o %"SCNu64 " %u %u  "
                          "%"SCNu64 " %u %u %u %u %"SCNi64 " %"SCNi64 " %"SCNi64
@@ -132,7 +135,7 @@ int ipc_shm_get_info(int id, struct shm_data **shmds)
                           &p->shm_dtim,
                           &p->shm_ctim,
                           &p->shm_rss,
-                          &p->shm_swp) != 16)
+                          &p->shm_swp) < 14)
                        continue; /* ivalid line, skipped */
 
                if (id > -1) {