Commit Graph

3722 Commits

Author SHA1 Message Date
Heiko Carstens 7afc23874e lscpu: add --offline option
Implement "--offline" option which only prints offline cpus. As a side effect
we can get rid of the internal "allcpus" flag, since if we want to print
informations for online and offline cpus we simply set both flags.

When reading sysfs attributes of cpus this is now done for all cpus, since
e.g. the topology informations of the online cpus may influence the
topology informations of the offline cpus. This mainly because online cpus
may contain masks which include offline cpus while offline cpus have a
missing topology directory.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 14:48:33 +02:00
Heiko Carstens 81137d1c0b lscpu: fix -e output
The modifier mod->allcpus must be set earlier and also must be used
earlier. The current code only reads sysfs attributes from online
cpus but skips offline cpus.
So initialize mod->allcpus earlier.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:37:52 +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 25dea0b565 lib,path: use write_all()
From: Heiko Carstens <heiko.carstens@de.ibm.com>

Since write() doesn't necessarily write the complete buffer with
one call we better use write_all() which takes care of this.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:37:41 +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 8148217b5b lib,path: move path access functions from lscpu into lib/path.c
A couple of these functions already have been copied to chcpu.c,
so it makes sense to move these functions into an own file.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 13:36:41 +02:00
Karel Zak b7fcd7ab6a setarch: minor changes to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 13:26:59 +02:00
Karel Zak 431772c5a9 pivot_root: minor changes to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 13:26:45 +02:00
Karel Zak d0983578b4 ipcs: minor changes to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 13:26:26 +02:00
Karel Zak 667229ae6a ctrlaltdel: minor changes to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 13:26:06 +02:00
Karel Zak 1a3cfe8800 arch: minor changes to usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 13:25:53 +02:00
Karel Zak 9fc7bf00ad Merge branch 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetit
* 'sys-utils' of https://github.com/kerolasa/lelux-utiliteetit: (29 commits)
  docs: add non-return function and if shorthand tips
  build-sys: fixes to USAGE_* macros
  ipcrm: check IPC syscalls
  ipcrm: add --verbose option
  ipcmk: allow high speed ipc creation
  ipcrm: add --all option
  docs: add long options to ipcs.1 man page
  docs: add long options to ipcrm.1 man page
  docs: add long options to ipcmk.1 man page
  docs: add --version to setarch.8
  docs: mention long options in ctrlaltdel.8
  ctrlaltdel: add version & help options
  docs: mention long options in pivot_root.8
  pivot_root: add version & help option
  ipcs: comment & white space clean up
  ipcs: include-what-you-use header check
  ipcs: add long options
  ipcrm: include-what-you-use header check
  ipcrm: refactor new and old main to share code
  ipcrm: exit if unknown error occurs
  ...
2011-09-27 12:56:48 +02:00
Davidlohr Bueso 7ef9fd7cdb mount: use common libs
Get rid of the local xmalloc.[c/h] files by using the global xalloc and
strutils libraries.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2011-09-27 12:49:52 +02:00
Karel Zak b9d18bc3f8 lscpu: add column names to --help
* use uppercase by default (only -p uses lowercase)
 * a little cleanup usage()

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 12:45:42 +02:00
Karel Zak 50c6ee4cb4 lscpu: gettextize two columns
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-27 12:26:02 +02:00
Karel Zak b926112726 agetty: test ECHO on c_lflag
Reported-by: xinglp <xinglp@gmail.com>
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=739522
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-26 12:34:10 +02:00
Sami Kerola 0c12134874 docs: add non-return function and if shorthand tips
Non-return functions should not be combined with `else' clause.

The if shorthands `var = e ? t : f;' need to fit to single line,
and if that does not look good use normal "if else" syntax.

Both tips are mentioned in email bellow.

http://www.spinics.net/lists/util-linux-ng/msg05152.html

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:52 +02:00
Sami Kerola 6f162034d0 build-sys: fixes to USAGE_* macros
The USAGE_BEGIN_TAIL is removed as unnecessary.

In between command specific options and --help & --version
USAGE_SEPARATOR is inserted. For now the separator is empty line.

The USAGE_MAN_TAIL is changed to take an argument.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:52 +02:00
Davidlohr Bueso 7678c735b2 ipcrm: check IPC syscalls
It's not enough to check errno for errors as the variable is not
reset, we also need to check the last syscall return value to
verify a problem. This addresses bogus msgqueue errors when
deleting keys.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:52 +02:00
Sami Kerola 99e89eded2 ipcrm: add --verbose option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:52 +02:00
Sami Kerola b332ef44cf ipcmk: allow high speed ipc creation
This commit will allow user to create quickly plenty of ipc
resources. Earlier the line bellow gave no satisfaction.

for i in $(seq 0 42); do ipcmk -Q; done

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:52 +02:00
Sami Kerola 3d0fc72d65 ipcrm: add --all option
An --all option will remove all ipc entries. The option takes
optional resource argument, which limits the removal to be
applied only the given resource entries.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 15:07:35 +02:00
Sami Kerola 5ccc85be82 docs: add long options to ipcs.1 man page
Includes few style fixes from Documentation/howto-man-page.txt
and align information by what is being said by The Open Group.

http://pubs.opengroup.org/onlinepubs/009604599/utilities/ipcs.html

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 9a9ff6bd59 docs: add long options to ipcrm.1 man page
Includes few style fixes from Documentation/howto-man-page.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola cbeb426144 docs: add long options to ipcmk.1 man page
Includes few style fixes from Documentation/howto-man-page.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola e0771cf881 docs: add --version to setarch.8
Includes few style fixes from Documentation/howto-man-page.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 1222d81809 docs: mention long options in ctrlaltdel.8
Includes other manual page maintenance fixes.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 028f7ed83f ctrlaltdel: add version & help options
Including other necessary changes to usage().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 8d3abdc0ae docs: mention long options in pivot_root.8
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 922eafb28a pivot_root: add version & help option
Including other necessary changes to usage().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 1e13900a3b ipcs: comment & white space clean up
Add to multiline comments to have left side stars, convert spaces
to tabs and indent preprocessor directives

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 3ab18da8a7 ipcs: include-what-you-use header check
Two includes added & a sort to alphabetical order.

ipcs.c should add these lines:
 #include <features.h>                   // for __GLIBC__
 #include <stddef.h>                     // for size_t

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 09f53dab0c ipcs: add long options
Includes necessary usage() changes.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 79092062a4 ipcrm: include-what-you-use header check
Three removes & a sort to alphabetical order.

ipcrm.c should remove these lines:
- #include <ctype.h>  // lines 29-29
- #include <sys/types.h>  // lines 18-18
- #include <unistd.h>  // lines 27-27

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:20 +02:00
Sami Kerola 8b69b6d6de ipcrm: refactor new and old main to share code
The code is now much more tidy, and as a bonus old main has
shares error printing with the `new' code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 14:25:14 +02:00
Sami Kerola 6054d3a774 ipcrm: exit if unknown error occurs
Previously for instance lack of memory space caused unknown
reason to be printed, and ipcrm tried to continue.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-17 13:12:33 +02:00
Karel Zak 277a6dd535 mount: check for target before source on remount
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=737091
Reported-by: Eric Paris <eparis@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-13 22:59:39 +02:00
Petr Uzel 3a18db62e6 lib: do not attempt to close(0) in sysfs_deinit()
If the 'open' fails we 'goto err' which runs 'sysfs_deinit()' on a 'cxt'
which hasn't been fully initialised. The 'dir_fd' is still 0, so
sysfs_deinit calls "close(0)".

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=714151
Reported-by: Diego Ercolani <diego.ercolani@gmail.com>
Analysed-by: Neil Brown <nfbrown@suse.com>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-13 11:38:13 +02:00
Karel Zak 5b66cfae91 chfn: remove non-ANSI definitions [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-13 11:21:47 +02:00
Karel Zak 913f560b98 build-sys: add err and errx to smatch no_return_funcs
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-13 11:15:43 +02:00
Karel Zak 57970842cc build-sys: add smatch data
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-13 11:10:18 +02:00
Sami Kerola 1b3b3f9fb9 ipcrm: add long options
With long options usage function had to be changed. The change
also takes libc error printing facilities to use, primarily to
get rid of execname & progname variables.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-12 21:27:07 +02:00
Sami Kerola c20b68231c ipcmk: include-what-you-use header check
Three removes & a sort to alphabetical order.

ipcmk.c should remove these lines:
- #include <string.h>  // lines 24-24
- #include <sys/types.h>  // lines 30-30
- #include <unistd.h>  // lines 29-29

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-12 21:27:07 +02:00
Sami Kerola 0eeec4152a ipcmk: remove camel casing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-12 21:27:07 +02:00
Sami Kerola c821a1256b ipcmk: validate numeric option arguments
Use strtoul_or_err() instead of atoi().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-12 21:27:07 +02:00
Sami Kerola f5b0684e34 ipcmk: remove useless code
Checking same return value twice does not make command any
better. Secondly the program_invocation_short_name is known to
work, so global progname variable does not add anything extra.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-12 21:27:06 +02:00
Sami Kerola 003f497604 ipcmk: add long options & fix usage()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-12 21:26:56 +02:00
Karel Zak d36ee054ca script: non-ANSI definition [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:18:16 +02:00
Karel Zak ac9b7477d2 whereis: non-ANSI definition [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:15:19 +02:00
Karel Zak f3970c99b7 logger: non-ANSI definition [smatch scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-09-12 16:13:58 +02:00