Commit Graph

410 Commits

Author SHA1 Message Date
Sami Kerola 56d45cfabe flock: use sysexit.h for all exit values
Additionally enhance readability of complex double "if shorthand's" by
making the segment to be few normal "if's".

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:45:27 +02:00
Sami Kerola e8cea66966 flock: use function attributes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:45:27 +02:00
Sami Kerola dc36ee2a4c flock: align with howto-usage-function.txt
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:45:20 +02:00
Sami Kerola d4eafec4d2 flock: use libc error printing facilities
Retire global progname variable and use warn{,x} and err{,x}
functions. As a side effect of using err function the occurences of
err variable had to be converted to referrals to errno variable.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:25:16 +02:00
Sami Kerola d89bfedff5 flock: move long_options struct to function scope
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:22:33 +02:00
Sami Kerola 75332f0f2b flock: fix coding style
Sanitize indentation, spacing, brace positions, comment line lenghts and
positions etc. This commit does not change a thing in code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:22:22 +02:00
Sami Kerola 1d803460f7 docs: align fallocate.1 with howto-man-page.txt
Add also earlierly missing --version to the manual.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-09-29 22:06:12 +02:00
Francesco Cosoleto d916761f3e ipcrm: fix wrong subject in error messages for -m, -q, -s id options
This makes error messages print 'id' instead of 'key' using id options.

Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-09-29 00:25:34 +02:00
Francesco Cosoleto 91b4ce6a73 ipcrm: use ternary operator in "(key|id) failed" message
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-09-29 00:25:32 +02:00
Francesco Cosoleto 14cbdb85dd ipcrm: add static keyword to some functions
Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
2011-09-29 00:25:30 +02: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
Petr Uzel 87d83b6ad2 flock: make flock(1) work on NFSv4
To pleace an exclusive lock on a file, NFSv4 requires
the file to be opened RW because of the emulation of flock()
by fcntl():

http://www.spinics.net/lists/linux-nfs/msg18502.html

So instead of O_RDONLY, open the file in O_RDWR if access()
indicates it is possible (unless shared lock is requested).

From: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:02:44 +02:00
Heiko Carstens 7bbb7829ca lscpu: stricter command line parsing
Disallow superfluous commands for lscpu like e.g. "lscpu bla" and let it
fail print the help text instead.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
2011-09-27 14:48:33 +02:00
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 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
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
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
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