summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcutils.c
Commit message (Collapse)AuthorAgeFilesLines
* ipcs: remove FIXME markupSami Kerola2015-01-071-4/+0Star
| | | | | | | | The ipc message q_qbytes information is not in /proc, and it is unlikely it will ever appear to there. Reference: https://lkml.org/lkml/2012/11/25/18 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ipcs: fix shmctl() usageKarel Zak2014-12-191-5/+7
| | | | | | | | | | | | | | | | | | | | | | 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>
* ipcs: fix two data type errors [AddressSanitizer]Sami Kerola2014-12-191-2/+2
| | | | | | | | | | | | | ==3218==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffa577e2b0 at pc 0x4501f9 bp 0x7fffa577e130 sp 0x7fffa577e108 WRITE of size 112 at 0x7fffa577e2b0 thread T0 #0 0x4501f8 in shmctl /home/users/aadgrand/LLVM/releases/ubuntu/final/llvm.src/projects/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc:2502 #1 0x48bd13 in ipc_shm_get_info /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcutils.c:157 #2 0x488884 in do_shm /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:279 #3 0x4844a8 in main /home/travis/build/kerolasa/lelux-utiliteetit/sys-utils/ipcs.c:175 #4 0x2afb3f8c176c (/lib/x86_64-linux-gnu/libc.so.6+0x2176c) #5 0x48408c in _start (/home/travis/build/kerolasa/lelux-utiliteetit/ipcs+0x48408c) Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ipcs: fix memleak in ipc_*_get_info functionsRuediger Meier2014-03-141-6/+0Star
| | | | | | | In case of error (maxid < 0) we do not enter following for loop. It will return 0 and free the structs afterwards because i is still 0. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: fix ipc_sem_get_info fallback caseRuediger Meier2014-03-141-11/+7Star
| | | | | | | | | "ipcs -s -i n" (case id >= 0) was broken since v2.22-254-g1e2418a if /sys is not usable. See also comments for commit "ipcs: fix ipc_msg_get_info fallback case". Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: fix ipc_shm_get_info fallback caseRuediger Meier2014-03-131-12/+7Star
| | | | | | | | | "ipcs -m -i n" (case id >= 0) was broken since v2.22-251-g61e14b4 if /sys is not usable. See also comments for commit "ipcs: fix ipc_msg_get_info fallback case". Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: fix ipc_msg_get_info fallback caseRuediger Meier2014-03-131-13/+8Star
| | | | | | | | | | | | | | | | "ipcs -q" (case id < 0) was broken since v2.22-256-g35118df if /sys is not usable. The main issue was that the use of msqid argument did not cleanly distinguished between "queue identifier" and "index of kernel's internal array". Also now the fallback case and the regular case behave more equally regarding it's return value (introducing another counter j). Note that the case id >= 0 now performs a slower lookup. This could be avoided but then we would better handle both case differently like it was before the above mentioned cleanup commit. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: cleanup jumplabel stlyesRuediger Meier2014-03-131-4/+4
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: fix size_t overflowKarel Zak2014-03-111-4/+4
| | | | | Addresses: https://github.com/karelzak/util-linux/issues/51 Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: fix compiler warning [clang -Wuninitialized]Karel Zak2013-03-201-3/+3
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: fix compiler warnings, use 64bit timeKarel Zak2012-12-201-3/+5
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: add --human readable size conversion optionSami Kerola2012-12-191-0/+40
| | | | | | | | | Introduces new function ipc_print_size() which will call size_to_human_string(), and handles the occasional '([k]bytes)' printing if default size format is requested. Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ipcs: make individual message queue id printing to use /procSami Kerola2012-11-231-2/+9
| | | | | | | | [kzak@redhat.com: - fix msgctl() call, move q_qbytes to ipc_msg_get_info] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: clean up do_msg(), and add ipc_msg_get_info()Sami Kerola2012-11-231-0/+114
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ipcs: make individual semaphore id printing to use /procSami Kerola2012-11-231-1/+37
| | | | | | | | | And reindent the print_shm() function. [kzak@redhat.com: move semctl(GET*...) calls to ipcutils.c] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: clean up do_sem(), and add ipc_sem_get_info()Sami Kerola2012-11-231-0/+109
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* ipcs: fix ipc_shm_get_info(), use callocKarel Zak2012-11-231-11/+15
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: clean up do_shm()Karel Zak2012-11-231-2/+11
| | | | | | | | - don't expect maxid as argument in ipc_shm_get_info() - if there is @id argument then use it everywhere in ipc_shm_get_info() - don't call shmctl() if not necessary in do_shm() Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: read shared memory values from /procSami Kerola2012-11-231-0/+138
| | | | | | | | [kzak@redhat.com: - move to ipcutils.{c,h}, - fix datatypes to be arch independent] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: determine ipc limits from /procSami Kerola2012-11-231-0/+89
Some of the limit values are not dynamic. Like in kernel these values are #defined. [kzak@redhat.com: - use better names for functions, - add ipcutils.{c,h} - read also shmmax from /proc] Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>