From: Ruediger Meier <sweet_f_a@gmx.de>
To: util-linux@vger.kernel.org
Subject: [PATCH 2/2] ipcs: --shmems, upward/backward compatibility
Date: Fri, 18 Mar 2016 12:49:18 +0100 [thread overview]
Message-ID: <1458301758-21853-3-git-send-email-sweet_f_a@gmx.de> (raw)
In-Reply-To: <1458301758-21853-1-git-send-email-sweet_f_a@gmx.de>
From: Ruediger Meier <ruediger.meier@ga-group.nl>
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 | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/sys-utils/ipcutils.c b/sys-utils/ipcutils.c
index c763cde..349e855 100644
--- a/sys-utils/ipcutils.c
+++ b/sys-utils/ipcutils.c
@@ -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) {
--
1.8.4.5
next prev parent reply other threads:[~2016-03-18 11:49 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-18 11:49 [PATCH 0/2] ipcs: more robust and compatible /proc parsing Ruediger Meier
2016-03-18 11:49 ` [PATCH 1/2] ipcs: make sure to parse whole lines for shm_data Ruediger Meier
2016-03-18 11:49 ` Ruediger Meier [this message]
2016-03-18 13:48 ` [PATCH 0/2] ipcs: more robust and compatible /proc parsing Karel Zak
2016-03-18 14:03 ` Ruediger Meier
2016-03-18 14:38 ` Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1458301758-21853-3-git-send-email-sweet_f_a@gmx.de \
--to=sweet_f_a@gmx.de \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox