Commit Graph

30 Commits

Author SHA1 Message Date
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
Karel Zak 7f8787d094 chcpu: fix memory leak
The CPU set has been allocated more than once.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 10:51:35 +02:00
Karel Zak a375d911c7 chcpu: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Stanislav Brabec 607274943b chcpu: Fix maximal number of CPUs
chcpu.c mixed maxcpus (number of cpus) and setsize (size of CPU bit
mask). It effectively limits number of CPUs to 1/8 of the supported
amount.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Michael Matz <matz@suse.de>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
2018-05-10 11:41:37 +02:00
Stanislav Brabec 538b50cb0a lscpu, chcpu: Avoid use of the old CPU macros
The old CPU macros are limited to 1024 cores. As a result, lscpu cannot
count sockets on large systems. Use new scalable macros.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Michael Matz <matz@suse.de>
2018-05-10 11:41:23 +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 b305445495 misc: consolidate all --help option descriptions
Now we are always using the same text also for commands
which had still hardcoded descriptions or where we can't
use the standard print_usage_help_options macro.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-27 12:28:36 +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
Sami Kerola 8791804065 misc: do not use plain 0 as NULL [smatch scan]
text-utils/tailf.c:69:21: warning: Using plain integer as NULL pointer

Since many 'struct option' has used zero as NULL make them more readable in
same go by reindenting, and using named argument requirements.

Reference: https://lwn.net/Articles/93577/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-02-20 12:58:49 +01:00
Yuri Chornoivan a7349ee315 docs: Fix word repetitions 2017-02-13 14:10:12 +01: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
Boris Egorov e3ca1312a2 sys-utils/disk-utils/lib: fix printf format types [cppcheck]
Fix 'invalidPrintfArgType' cppcheck warnings

Signed-off-by: Boris Egorov <egorov@linux.com>
2015-06-25 12:08:45 +02:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
This adds a concise description of a tool to its usage text.

A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-01-06 11:27:38 +01:00
Sami Kerola f627750083 textual: use version printing macro everywhere
Only mount, umount, and blkid remains not using the macro because they
are print also library references.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:23 +02:00
Karel Zak 9a7d05fedb chcpu: cleanup stdout/stderr usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 11:23:16 +01:00
Karel Zak 48fc00c1c7 chcpu: cleanup return codes
The code currently always return EXIT_SUCCESS, that's strange. It
seems better to return 0 on success, 1 on complete failure and 64 on
partial success.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-05 11:06:59 +01:00
Karel Zak 69e74525bb chcpu: clean up error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-14 23:33:59 +02:00
Karel Zak ca01695b77 lib/path: rename functions to be more explicit
... and to have names compatible with lib/sysfs.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak 20da61dc8b chcpu: use err_exclusive_options()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:25:19 +02:00
Bernhard Voelker 7007991f6f docs: fix typos found by misspellings
The tool misspellings (https://github.com/lyda/misspell-check)
detected several typos. Command used:

  $ git ls-files | grep -v ^po/ | misspellings -f -

* Documentation/releases/v2.18-ReleaseNotes: Fix typo in news entry.
* NEWS: Likewise.
* config/texinfo.tex: Fix typo in comments.
* libmount/src/context.c: Fix typo in comment.
* libmount/src/fs.c: Likewise.
* login-utils/login.c: Likewise.
* login-utils.su.1: Fix typo in man page.
* sys-utils/chcpu.c: Fix typo in error message.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2012-07-09 16:56:30 +02:00
Sami Kerola 264a6b0ab7 chcpu: use exclusive_option()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:59 +02:00
Sami Kerola efb8854f4c sys-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:49:40 +02:00
Sami Kerola 7cebf0bb4f docs: corrections to FSF license files, and postal address
The COPYING and Documentation/licenses/COPYING* files are being
replaced by files from GNU web site.

http://www.gnu.org/licenses/gpl-2.0.txt
http://www.gnu.org/licenses/lgpl-2.1.txt

Postal addresses to FSF in other files are updated to match with the
address in license files.

Reference: http://lists.gnu.org/archive/html/freefont-announce/2005-04/msg00001.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-24 14:13:35 +01:00
Sami Kerola 4b11df2cf5 chcpu: use appropriate variable type [cppcheck]
[sys-utils/chcpu.c:251]: (style) Checking if unsigned variable 'maxcpus' is less than zero.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-08 14:17:29 +01:00
Karel Zak 701e2b8e53 chcpu: check get_max_number_of_cpus() result properly
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-01 12:26:32 +01:00
Petr Uzel 960cf5737e misc: use %m in format string instead of %s and strerror(errno)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:46:07 +02:00
Heiko Carstens 5b88ce6a17 chcpu: provide better user feedback
Instead of printing error messages like "I/O resource busy" which are
supplied by strerror, give better feedback if the reason of failure
is known.
E.g. taking the last cpu offline cannot succeed, therefore print a
message that gives this "hint".

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:37:50 +02:00
Heiko Carstens 9bc2b4b185 chcpu: convert to use lib/path.c
Use the common path access functions. In order to simplify chcpu also implement
and use path_writestr() which writes a string to the path specified.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:36:54 +02:00
Heiko Carstens 59fb133a02 chcpu,cpuset: reduce code duplication for cpu list parsing
Reduce code duplication and print better error message if an
unsupported cpu number was passed.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-10 00:00:35 +02:00
Heiko Carstens 0b57c6c229 chcpu: new tool
chcpu can modify the logical state of CPUs. It can enable and disable CPUs,
scan for new CPUs, change the CPU dispatching mode of the underlying
hypervisor and request (configure) or give logical CPUs back (deconfigure)
to the the underlying hypervisor.

This is quite useful if you work a lot with virtual servers, since doing all
the configuration stuff directly via sysfs becomes a pain.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-08-22 13:56:31 +02:00