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>
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>
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>
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>
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>
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>
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>
* '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
...
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>
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>
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>
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>
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>
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>
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>
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>
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>
However I'd like to see one change if you don't object: printing just "N" or
"Y" instead of "No" and "Yes" in the human readable output looks a bit ugly to
me.
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
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>