The util-linux code was previously aligned to use @localstatedir@ and
the util-linux build system was set to override the default to use /run.
Current GNU Coding Standards introduced the @runstatedir@ variable
for this purpose. Lets use that instead.
The GNU default for @runstatedir@ is ${localstatedir}/run so util-linux
still override the default to be /run to preserve the status quo from
before. The only difference is that you'll now pass --runstatedir to
override the location on the command line instead of --localstatedir.
(FWIW, Debhelper in compat 11 will automatically start passing
--runstatedir=/run to all autotools configured builds. It already
passes --localstatedir=/var (to avoid it ending up with the GNU default
/usr/local/var) which breaks the util-linux build system code that
tries to default it to /run. This change will thus allow util-linux
and debhelper to work better together and avoid the need for a
package-specific override.)
Relevant historic commits:
* commit 07a16b9d1e
"build-sys: change --localstatedir to /run"
* commit 80c51185d5
"uuidd: use run configured state directory"
* commit 01c5b78794
"agetty: use configured run state directory"
[kzak@redhat.com: - add $runstatedir fallback for autoconf < 2.70
- check for unmodified $localstatedir]
CC: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Signed-off-by: Karel Zak <kzak@redhat.com>
This includes atleast the native multiarch path in the paths to search.
(Maybe also other multiarch paths should also be searched? But atleast
this is a first step.)
Before this change (on Debian):
$ whereis libc
libc: /usr/share/man/man7/libc.7.gz
After this change:
$ whereis libc
libc: /usr/lib/x86_64-linux-gnu/libc.so /usr/lib/x86_64-linux-gnu/libc.a /usr/share/man/man7/libc.7.gz
Addresses: https://bugs.debian.org/856968
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
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>
Clang analyzer warnings:
Dead store, Dead initialization:
lib/mbsedit.c:154:8: warning: Value stored to 'in' during its initialization is never read
char *in = (char *) &c;
^~ ~~~~~~~~~~~
misc-utils/findmnt-verify.c:129:14: warning: Value stored to 'cn' during its initialization is never read
const char *cn = tgt;
^~ ~~~
Dead store, Dead increment:
sys-utils/hwclock.c:1461:2: warning: Value stored to 'argv' is never read
argv += optind;
^ ~~~~~~
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The old output is horrible and useless when more devices specified.
The old format is also too tricky if more signatures detected. The new
output uses one line for each signature, prefixed by device name.
For example my workstation:
# wipefs /dev/sda* /dev/sdb*
DEVICE OFFSET TYPE UUID LABEL
sda 0x1fe PMBR
sda 0x37e4895e00 gpt
sda 0x200 gpt
sda1 0x1fe vfat F2BC-BFEC EFI
sda1 0x0 vfat F2BC-BFEC EFI
sda1 0x36 vfat F2BC-BFEC EFI
sda2 0x438 ext4 c5490147-2a6c-4c8a-aa1b-33492034f927 BOOT
sda3 0x438 ext4 196972ad-3b13-4bba-ac54-4cb3f7b409a4 HOME
sda4 0x438 ext4 d834bc84-0089-4be1-9013-cd8bf35d5ffa ROOT
sda5 0x438 ext4 e8ce5375-29d4-4e2f-a688-d3bae4b8d162 WINE
sda6 0xff6 swap 210337c6-f8b5-4d65-aab5-a0f343fa9ad4 SWAP
sdb 0x200 gpt
sdb 0x1fe dos
sdb1 0x438 ext4 6467a684-0d10-4f61-a301-67bb26934d90
This patch add --noheadings, --json and --output.
Signed-off-by: Karel Zak <kzak@redhat.com>
The commit 92296e9ba2 introduces "try
all permutations for the same superblock". This feature has to be also
available if -o and -t is specified.
Signed-off-by: Karel Zak <kzak@redhat.com>
The same FS/RAID/PT signature may be detected by more ways and on more
places on the device. The libblkid returns only the first detected
signature by default. This patch use blkid_probe_hide_range() to
re-scan device for all possible permutations of the same signature.
For example the default wipefs(8) output as well as --no-act output will
contains primary as well as backup GPT signature now.
Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'help-description' of https://github.com/rudimeier/util-linux:
misc: update --help content again
login: add --help text
blockdev: improve --help and man page
misc: consolidate all --help option descriptions
misc: introduce print_usage_help_options()
misc: revert to the old USAGE_HELP strings
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>
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>
$ ./uuidparse --unknownopt
Segmentation fault (core dumped)
Hehe, this is the first real bug found by 'make checkusage'.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* 'usage-part2' of https://github.com/rudimeier/util-linux:
misc: cosmetics, remove argument from usage(FILE*)
misc: cosmetics, remove argument from usage(int)
misc: never use usage(stderr)
misc: never use usage(ERROR)
misc: cleanup and fix --unknownopt issues
flock, getopt: write --help to stdout and return 0
tools: add checkusage.sh
This command will analyze and print information about UUID's. The command
is based on libuuid/src/uuid_time.c but modified to use libsmartcol.
[kzak@redhat.com: - minor coding style changes]
Reference: http://marc.info/?l=util-linux-ng&m=149735980715600&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We are using better/shorter error messages and somtimes
also errtryhelp().
Here we fix all cases where the usage function took
an int argument for exit_code.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
... and use errtryhelp() instead of usage().
Note in past "getopt --help" returned 2. But it is otherwise
documented and was just a mistake IMO. See the unreachable exit(0)
which was removed here: d1d03b54
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* '170622' of github.com:jwpi/util-linux:
Docs: move option naming to howto-contribute.txt
Docs: update howto-usage-function.txt
Docs: add a comment for constants to boilerplate.c
include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
Nowadays all our regular commands have --help options.
test_uuidd does not use translations anyways.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
As discussed on the mailing list. We fix all places
where the non-working define STRTOXX_EXIT_CODE was used.
Regarding tunelp, also see 7e3c80a7.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
These tools have special exit codes. They got changed mistakenly.
See:
findfs 0e1fa6b6
fsck 658c0891
fsck.cramfs 922ec175
mkfs.cramfs 16154b1f
tunelp 2ab428f6
FIXME: STRTOXX_EXIT_CODE doesn't work as it should.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
We can use errtryhelp() now and never print usage to stderr.
One may improve all these "bad usage" messages.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
The current behavior is to report error and continue, it seems strange:
# blockdev --setro /dev/sdc
# wipefs -a /dev/sdc
wipefs: /dev/sdc: failed to erase xfs magic string at offset 0x00000000: Operation not permitted
/dev/sdc: 4 bytes were erased at offset 0x00000000 (xfs): 58 46 53 42
^^^^^^^^^^^
not true
The patch calls err() to exit.
Reported-by: Vratislav Podzimek <vpodzime@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
The rename(1) can exit early when replace expression and replacement are
identical string. It is also appropriate to change return value in this
case to 'nothing was renamed'.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
(Original patch and commit message edited by Rudi.)
gcc-7 adds -Wimplicit-fallthrough=3 to our default flag -Wextra.
This warning can be silenced by using comment /* fallthrough */
which is also recognized by other tools like coverity. There are
also other valid comments (see man gcc-7) but we consolidate this
style now.
We could have also used __attribute__((fallthrough)) but the comment
looks nice and does not need to be ifdef'ed for compatibility.
Reference: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=7652
Reference: https://developers.redhat.com/blog/2017/03/10/wimplicit-fallthrough-in-gcc-7/
Reviewed-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Suggested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Now lsblk uses --list when --sort <column> is specified. This patch
allows to specify --tree to overwrite this default behavior add to
force tree-like output. In this case tree branches are sorted by the
<column>.
$ lsblk --sort SIZE
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda2 8:2 0 200M 0 part /boot
sda1 8:1 0 200M 0 part /boot/efi
sda6 8:6 0 7.8G 0 part [SWAP]
sda5 8:5 0 35.1G 0 part /home/misc
sda4 8:4 0 50G 0 part /
sdb1 8:17 0 74.5G 0 part /home/archive
sdb 8:16 0 74.5G 0 disk
sda3 8:3 0 130.3G 0 part /home
sda 8:0 0 223.6G 0 disk
$ lsblk --sort SIZE --tree
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdb 8:16 0 74.5G 0 disk
└─sdb1 8:17 0 74.5G 0 part /home/archive
sda 8:0 0 223.6G 0 disk
├─sda2 8:2 0 200M 0 part /boot
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda6 8:6 0 7.8G 0 part [SWAP]
├─sda5 8:5 0 35.1G 0 part /home/misc
├─sda4 8:4 0 50G 0 part /
└─sda3 8:3 0 130.3G 0 part /home
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/prlimit.c: In function 'do_prlimit':
sys-utils/prlimit.c:367:16: warning: format '%ju' expects argument of type 'uintmax_t', but argument 2 has type 'rlim_t {aka long long unsigned int}' [-Wformat=]
printf("<%ju", new->rlim_cur);
lib/plymouth-ctrl.c: In function 'open_un_socket_and_connect':
lib/plymouth-ctrl.c:88:20: warning: passing argument 2 of 'connect' from incompatible pointer type [-Wincompatible-pointer-types]
ret = connect(fd, &su, offsetof(struct sockaddr_un, sun_path) + 1 + strlen(su.sun_path+1));
^
In file included from lib/plymouth-ctrl.c:35:0:
/usr/include/sys/socket.h:314:5: note: expected 'const struct sockaddr *' but argument is of type 'struct sockaddr_un *'
int connect (int, const struct sockaddr *, socklen_t);
login-utils/last.c: In function 'list':
login-utils/last.c:506:54: warning: pointer targets in passing argument 4 of 'dns_lookup' differ in signedness [-Wpointer-sign]
r = dns_lookup(domain, sizeof(domain), ctl->useip, p->ut_addr_v6);
^
login-utils/last.c:291:12: note: expected 'int32_t * {aka int *}' but argument is of type 'unsigned int *'
static int dns_lookup(char *result, int size, int useip, int32_t *a)
^~~~~~~~~~
In file included from sys-utils/hwclock-cmos.c:92:0:
sys-utils/hwclock.h:67:32: warning: 'struct timeval' declared inside parameter list will not be visible outside of this definition or declaration
extern double time_diff(struct timeval subtrahend, struct timeval subtractor);
misc-utils/test_uuidd.c: In function 'create_nthreads':
misc-utils/test_uuidd.c:187:19: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
proc->pid, (int) th->tid, th->index));
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
* assume ncursesw headers in ncursesw/ directory only
* prefer long paths, <term.h> and <ncurses.h> should be last
possibility
* fix typos
Signed-off-by: Karel Zak <kzak@redhat.com>
* use proper paths to term.h
* keep ncurses support optional
* link with TINFO_LIBS (-ltinfo), or fallback to NCURSES_LIBS (-ltinfo -lncurses)
* don't include unnecessary ncurses.h (term.h is enough)
Signed-off-by: Karel Zak <kzak@redhat.com>