Commit Graph

16 Commits

Author SHA1 Message Date
Karel Zak 8803c8d4ab lsmem: check errno after strto..()
Addresses: https://github.com/karelzak/util-linux/issues/1356
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-07-20 11:34:53 +02:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Sami Kerola 523de2ec6f chmem: add initilizer [clang]
warning: use of GNU empty initializer extension [-Wgnu-empty-initializer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2019-01-02 14:40:40 +01:00
Ruediger Meier 77845f7bd7 ipcs,chmem: fix access() usage
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>
2018-06-25 16:49:00 +02:00
Karel Zak 8ca312798c chmem: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak c71665adb5 chmem: cleanup includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-23 15:49:22 +02:00
Karel Zak 96b6448d5d chmem: cleanup usage()
Just to be compatible with another u-l tools.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-20 12:37:04 +02:00
Gerald Schaefer 60a7e9e94e lsmem/chmem: add memory zone awareness
With this patch, valid memory zones can be shown with lsmem, and chmem can
set memory online/offline in a specific memory zone, if allowed by the
kernel. The valid memory zones are read from the "valid_zones" sysfs
attribute, and setting memory online to a specific zone is done by
echoing "online_kernel" or "online_movable" to the "state" sysfs
attribute, in addition to the previous "online".

This patch also changes the default behavior of chmem, when setting memory
online without specifying a memory zone. If valid, memory will be set
online to the zone Movable. This zone is preferable for memory hotplug, as
it makes memory offline much more likely to succeed.

Signed-off-by: Gerald Schaefer <gerald.schaefer@de.ibm.com>
2017-10-20 12:37:04 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
changed in include/c.h and applied via sed:

  sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
  sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
Consolidate --help and --version descriptions. We are
now able to align them to the other options.

We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:26:19 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 1ea4e7bd8d chmem: don't use scanf format for printf
The compiler had not complained here because both macros are
probably the same.

But gettext issued a funny warning:
sys-utils/chmem.c:67: warning: Although being used in a format string position, the msgid is not a valid C format string. Reason: The string ends in the middle of a directive.

CC: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-04-10 15:41:21 +02:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Karel Zak a5c4535b0d lsmem: add Copyright
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-11-09 10:02:32 +01:00
Heiko Carstens 30e1ea8ba1 chmem: new tool
Move the s390 specific chmem tool to util-linux.

The chmem tool was originally written in perl and is part of the
s390-tools package which can be found here:
https://www.ibm.com/developerworks/linux/linux390/s390-tools.html

Given that the tool is architecture independent, there is no reason to
keep it in an s390 specific repository. It seems to be useful for
other architectures as well.

This patch converts the tool to C and adds it to util-linux, while the
command line options stay compatible. The only exception is the option
"-v" which used to be the short form of "--version". That got changed
to "-V" so it behaves like most other tools contained within
util-linux.

The chmem tool can be used to set memory online or offline. This can
be achieved by specifying a memory range:

Memory Block 19 (0x0000000130000000-0x000000013fffffff) disabled

or by specifying a size where chmem will automatically select memory
blocks:

Memory Block 21 (0x0000000150000000-0x000000015fffffff) disable failed
Memory Block 18 (0x0000000120000000-0x000000012fffffff) disabled
Memory Block 17 (0x0000000110000000-0x000000011fffffff) disabled
Memory Block 16 (0x0000000100000000-0x000000010fffffff) disabled
Memory Block 15 (0x00000000f0000000-0x00000000ffffffff) disabled

or by specifying memory block numbers instead of address ranges:

Memory Block 15 (0x00000000f0000000-0x00000000ffffffff) disabled
Memory Block 16 (0x0000000100000000-0x000000010fffffff) disabled
Memory Block 17 (0x0000000110000000-0x000000011fffffff) disabled
Memory Block 18 (0x0000000120000000-0x000000012fffffff) disabled

This is based on a patch from Clemens von Mann.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2016-11-09 10:02:32 +01:00