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>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
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>
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>
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>
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>
==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>
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 -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 -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 -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>
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>
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>
- 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>
[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>
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>