summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcs.c
diff options
context:
space:
mode:
authorKarel Zak2014-12-19 13:42:41 +0100
committerKarel Zak2014-12-19 13:42:41 +0100
commit929c257548049f34d357355fc72a6f1540f751cf (patch)
tree954a8a9338ce5b59fdf16923d2ecbc4dc8e49fff /sys-utils/ipcs.c
parenttests: don't check the current ipcs limits (diff)
downloadkernel-qcow2-util-linux-929c257548049f34d357355fc72a6f1540f751cf.tar.gz
kernel-qcow2-util-linux-929c257548049f34d357355fc72a6f1540f751cf.tar.xz
kernel-qcow2-util-linux-929c257548049f34d357355fc72a6f1540f751cf.zip
ipcs: fix shmctl() usage
The function shmctl() has to be called with 'struct shmid_ds', and if you need 'struct shminfo' then the right way is to cast: bad way: struct shm_info info; shmctl(0, SHM_INFO, &info); right way: struct shmid_ds buf; struct shm_info *info; shmctl(0, SHM_INFO, &buf); info = (struct shm_info *) &buf); The patch also fixes bug in ipc_shm_get_limits() where is missing lim->shmmax in code based on shmctl(). Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/ipcs.c')
-rw-r--r--sys-utils/ipcs.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 9ce536612..a2d7f12ad 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -209,9 +209,11 @@ static void do_shm (char format, int unit)
case STATUS:
{
int maxid;
- struct shm_info shm_info;
+ struct shmid_ds shmbuf;
+ struct shm_info *shm_info;
- maxid = shmctl (0, SHM_INFO, (struct shmid_ds *) &shm_info);
+ maxid = shmctl (0, SHM_INFO, &shmbuf);
+ shm_info = (struct shm_info *) &shmbuf;
if (maxid < 0) {
printf (_("kernel not configured for shared memory\n"));
return;
@@ -234,11 +236,11 @@ static void do_shm (char format, int unit)
"pages resident %ld\n"
"pages swapped %ld\n"
"Swap performance: %ld attempts\t %ld successes\n"),
- shm_info.used_ids,
- shm_info.shm_tot,
- shm_info.shm_rss,
- shm_info.shm_swp,
- shm_info.swap_attempts, shm_info.swap_successes);
+ shm_info->used_ids,
+ shm_info->shm_tot,
+ shm_info->shm_rss,
+ shm_info->shm_swp,
+ shm_info->swap_attempts, shm_info->swap_successes);
return;
}