summaryrefslogtreecommitdiffstats
path: root/sys-utils/setarch.c
Commit message (Collapse)AuthorAgeFilesLines
* setarch: avoid NULL dereference [coverity check]Karel Zak2019-05-281-1/+1
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* misc: consolidate version printing and close_stdout()Karel Zak2019-04-161-7/+6Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: add new e2k subarchesAndrew Savchenko2019-04-091-0/+13
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* various: fix 'uninitialized when used' warnings [clang]Sami Kerola2019-02-181-1/+1
| | | | | | | This change fixes "warning: variable 'var' may be uninitialized when used here [-Wconditional-uninitialized]" warnings reported in various files. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: don't return address of automatic variableAndreas Schwab2019-01-221-1/+1
| | | | | | | | | | | On architectures without special personalities setarch uses the contents of a local variable with automatic storage duration after return from the function, causing it to report a spurious error. $ setarch m68k setarch: Kernel cannot set architecture to m68k Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
* setarch: fix obscure sparc32bash use-caseKarel Zak2018-11-221-10/+18
| | | | | Reported-by: Carlos Santos <casantos@datacom.com.br> Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: make <arch> optionalKarel Zak2018-08-071-9/+18
| | | | | | | | | | | | | | Let's allow to change personality flags without execution domain modification. Old way: setarch `arch` --addr-no-randomize myprog New way: setarch --addr-no-randomize myprog Addresses: https://github.com/karelzak/util-linux/issues/668 Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: split set_arch() function to small functionsKarel Zak2018-08-061-35/+73
| | | | | | | It seems better to keep the code more flexibile by small one-purpose functions than by one huge monster. Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: add another PER_LINUX32 aliases for ppcleKarel Zak2018-06-141-0/+2
| | | | | | | | | The big-endian version maps generic "ppc" and "ppc32" aliases to PER_LINUX32. It seems that we can do the same for little-endian. Note that SYS_personality does not care about LE/BE, it's 32 or 64 bit. Signed-off-by: Karel Zak <kzak@redhat.com>
* sys-utils: use errexec()Karel Zak2018-02-011-4/+3Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: minor code clean upSami Kerola2017-12-041-23/+15Star
| | | | | | | | | | | | Remove global variable, skip unnecessary comparison, and remove version printing function when a simple printf() can do the job. In same go fix compiler warning. sys-utils/setarch.c:296:4: warning: null argument where non-null required (argument 2) [-Wnonnull] execl("/bin/bash", NULL); Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* misc: consolidate macro style USAGE_HELP_OPTIONSRuediger Meier2017-06-291-1/+1
| | | | | | | | | 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>
* misc: introduce print_usage_help_options()Ruediger Meier2017-06-271-2/+1Star
| | | | | | | | | | | | 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>
* setarch: use errtryhelp()Ruediger Meier2017-06-221-16/+6Star
| | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* Use --help suggestion on invalid optionKarel Zak2016-12-191-1/+1
| | | | | | | | 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>
* setarch: let's keep analyzer happy [coverity scan]Karel Zak2016-10-051-0/+1
|
* misc: Fix various typosSebastian Rasmussen2016-05-311-1/+1
| | | | | | | Fix various typos in error messages, warnings, debug strings, comments and names of static functions. Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
* setarch: add "exec" message to --verboseRuediger Meier2016-03-221-2/+5
| | | | | | Also we don't need fflush() in non-verbose case. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* setarch: fix personality syscall return code checkDmitry V. Levin2016-03-071-2/+12
| | | | | | | | | | | | | | Depending on architecture and kernel version, personality syscall is either capable or incapable of returning an error. If the return value is not an error, then it's the previous personality value, which can be an arbitrary value undistinguishable from an error value. To make things clear, a second call is needed. For more details about personality syscall peculiarities see https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=glibc-2.22-637-ge0043e17dfc5 Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* setarch: fix regression for sparc buildsWaldemar Brodkorb2015-03-301-1/+1
| | | | | | | | | With following commit: 5edb0ea6bbd57dd916417737f98c9109dc1ecb5b Sparc cross-compile fails. Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
* setarch: print error when command runs without argumentsSami Kerola2015-02-191-1/+1
| | | | | | | | | | | | $ ./setarch Segmentation fault (core dumped) $ coredumpctl gdb ... Program terminated with signal SIGSEGV, Segmentation fault. 301 if (*argv[1] != '-') { Reference: 5edb0ea6bbd57dd916417737f98c9109dc1ecb5b Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: fix typo (missing braces) for ppcleRuediger Meier2015-02-101-3/+3
| | | | | | | Introduced in 77eb13b9, noticed on ppc64le. CC: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* setarch: fix --listKarel Zak2015-01-281-1/+1
| | | | | | | | | | $ ./setarch --list . . setarch: no architecture argument specified Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: cleanup options usageKarel Zak2015-01-121-28/+38
| | | | | | | | | * call --help, --verbose and --list from one place only * add 'archwrapper' variable to detect when called by symplink * make --list available only got setchar(8) (but no for symlinks) Reported-by: Benno Schulenberg <bensberg@justemail.net> Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: differentiate between "unrecognized" and "cannot set"Benno Schulenberg2015-01-121-1/+1
| | | | | | | | | When the provided string does not match any architecture that setarch knows about, the response stays "Unrecognized architecture", but when trying to set the specified architecture does not have any effect, then respond with "Kernel cannot set architecture to...". Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: list the options of setarch in a more alphabetical orderBenno Schulenberg2015-01-061-6/+8
| | | | Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* setarch: make the usage synopsis comprehensible for translatorsBenno Schulenberg2015-01-061-3/+4
| | | | | | | | Use two separate strings for the two different forms of setarch, instead of filling in an untranslated word into a single string. Also use the standard angular brackets for nonliteral arguments. Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
* textual: add a docstring to most of the utilitiesBenno Schulenberg2015-01-061-0/+4
| | | | | | | | | 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>
* setarch: use personality() system call when it is availableSami Kerola2014-09-191-4/+6
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: reindent codeSami Kerola2014-09-191-259/+248Star
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: add generic support for setarch $(uname -m) ...Ruediger Meier2014-05-291-0/+16
| | | | | Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl> Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: add shortcut binary uname26Ruediger Meier2014-05-221-0/+1
| | | | | | | | | | There are some uname26 binaries flying around. Let's make it available everywhere. Internal SUSE references: fate313476, sr226509 CC: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* setarch: flush output streams before execRuediger Meier2014-05-221-0/+3
| | | | | | | | | | | | | | | | | | | This fixes the following (non-deterministic) discrepancy: $ setarch x86_64 -RFZLvXBIST3 --uname-2.6 echo success Switching on READ_IMPLIES_EXEC. Switching on ADDR_LIMIT_32BIT. Switching on SHORT_INODE. Switching on WHOLE_SECONDS. Switching on STICKY_TIMEOUTS. Switching on ADDR_LIMIT_3GB. Switching on UNAME26. success $ setarch x86_64 -RFZLvXBIST3 --uname-2.6 echo success &> /tmp/bla; cat /tmp/bla success Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* setarch: Fix ppc64le architecturesAnton Blanchard2014-04-071-0/+6
| | | | | | | setarch currently fails on ppc64le because it tries to use big endian architecture names. Fix it. Signed-off-by: Anton Blanchard <anton@samba.org>
* setarch: prefer preprocessor rather than autotools checkSami Kerola2013-08-011-11/+11
| | | | | | | It seems to be pointless to spend time in ./configure phase when preprocessor has to perform #ifndef check anyway. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: clean up usage()Sami Kerola2013-04-091-23/+21Star
| | | | | | Requested-by: Karel Zak <kzak@redhat.com> References: http://marc.info/?l=util-linux-ng&m=136516351523680&w=2 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: add option to list settable architecturesSami Kerola2013-04-051-3/+15
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* translation: unify exec error messagesSami Kerola2013-02-061-2/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: fix compiler warning [-Wmissing-prototypes]Karel Zak2012-07-161-1/+2
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: disallow unknown command line optionsSami Kerola2012-06-171-1/+6
| | | | | | | | | | Exit with instruction to run --help if unknown option is encountered. Before the following example printed error, but resulted to an attempt to run argument. $ x86_64 -x ls Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: do not use -1 as array index [cppcheck]Sami Kerola2012-06-091-3/+3
| | | | | | | | | Negative array index does technically work, but looks awkward and can confuse static analyser such as cppcheck. [sys-utils/setarch.c:267]: (error) Array index -1 is out of bounds Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* sys-utils: verify writing to streams was successfulSami Kerola2012-04-041-0/+2
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: minor changes to usage()Karel Zak2011-09-271-6/+9
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: add version printingSami Kerola2011-09-101-2/+15
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: use program_invocation_short_nameSami Kerola2011-09-101-13/+2Star
| | | | | | Trust that the c.h is setting program name correctly. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: move options struct to function scopeSami Kerola2011-09-101-21/+21
| | | | Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* setarch: add --uname-2.6 option for personality flag UNAME26Ben Hutchings2011-08-291-3/+15
| | | | | | | [kzak@redhat.com: - minor change in usage()] Signed-off-by: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Karel Zak <kzak@redhat.com>
* setarch: fix compiler warnings [-Wsign-compare]Karel Zak2011-08-011-3/+2Star
| | | | Signed-off-by: Karel Zak <kzak@redhat.com>
* fstrim, setarch: replace error() with err()Francesco Cosoleto2011-06-081-9/+8Star
| | | | | | | | | | This should improve a bit the portability as error() is a GNU extension and util-linux provides fallbacks for err.h functions. Fix compilation with icc, broken due to a reference to `__builtin_va_arg_pack' in error.h using the -gcc default option. Signed-off-by: Francesco Cosoleto <cosoleto@gmail.com>
* move struct option to .rodataKarel Zak2011-03-031-1/+1
| | | | | | | It does not make sense to have writable large arrays of "struct option" on the stack. Signed-off-by: Karel Zak <kzak@redhat.com>