summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcutils.c
Commit message (Collapse)AuthorAgeFilesLines
* ipcs: check return value when read from /proc [coverity scan]Karel Zak2019-05-231-3/+6
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs,chmem: fix access() usageRuediger Meier2018-06-251-6/+6
| | | | | | | | | | | Some mistakes happened lately when switching from path_exist() to ul_path_access(). See f09a98de and 8ca31279. This caused ipcs test failures when running i386 binaries on x86_64 hosts, because the syscall fallback was always used. That's why I reviewed all similar changes and found another one in chmem. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: use new ul_path_* APIKarel Zak2018-06-211-17/+16Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: fix memory leak [coverity scan]Karel Zak2017-10-121-1/+5
| | | | | | It's not important, but let's keep static analyzes happy. Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* ipcs: make static analyzer happy [clang analyze]Karel Zak2016-03-291-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* ipcs: --shmems, upward/backward compatibilityRuediger Meier2016-03-181-1/+4
| | | | | | | | | | | | 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>
* ipcs: make sure to parse whole lines for shm_dataRuediger Meier2016-03-181-3/+4
| | | | | | | | | | | | | We want to parse 16 columns _per_row_ without mixing them up. The existing code is unsafe for more or less columns and could even run into endless loops. This patch assures that we parse row-wise and really skip lines with columns != 16. Probably somehow we could have also done this with fscanf() only. Using fgets() additionally makes the code more easy to read and to improve later. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* ipcs: fix ipc_sem_get_limits()Karel Zak2015-09-151-1/+1
| | | | | | Reported-by: https://github.com/AndrewIrcha Addresses: https://github.com/karelzak/util-linux/commit/e5995acda2d3d55ba4d926741ddd789c9776f1e7#commitcomment-13200369 Signed-off-by: Karel Zak <kzak@redhat.com>
* 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>