Commit Graph

1773 Commits

Author SHA1 Message Date
Karel Zak bd9a35c6ce hardlink: (man) add AVAILABILITY
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-06 14:37:34 +01:00
Karel Zak 117f4d8bf4 Merge branch 'hardlink' of https://github.com/rudimeier/util-linux into hardlink
* 'hardlink' of https://github.com/rudimeier/util-linux: (25 commits)
  hardlink: add first simple tests
  hardlink: util-linux usage
  hardlink: fix compiler warnings
  hardlink: style indentations and license header
  hardlink: enable build with and without pcre2
  fixes for the fixes
  temporal fix before re-patch (updates from Fedora repo)
  Update hardlink.1
  Fixed version number, added changelog about Todd Lewis' patch
  exclude files via pcre
  Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989)
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file
  Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
  spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file
  Mention -f option in the man page
  do not allow to hardlink files across filesystems by default (#786719) (use -f option to override)
  fix possible buffer overflows, integer overflows, update man page
  fix URL and remove mmap() (#676962, #672917)
  - update docs to describe highest verbosity -vv option (#210816) - use dist Resolves: 210816
  mostly spec cleanup
  ...
2019-02-06 13:55:20 +01:00
Karel Zak f90d8b8bcc cal: use standout mode on monochrome terminals
The function colors_init() checks for colors, it means it fails
on monochrome terminals, but cal(1) in this case still need to
highlight the current day.

Reported-by: Nuno Silva <nunojsilva@ist.utl.pt>
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-02-04 14:20:03 +01:00
Karel Zak 8fd512e932 logger: (man) add info about rewrite and authors
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-29 15:59:41 +01:00
Karel Zak bd0029f6be logger: (man) make more obvious that --server/socket is required
The options --tcp/udp specify only how, but no where.

Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-29 15:44:13 +01:00
Karel Zak 1c4a2600cc logger: concatenate multiple lines of MESSAGE into a single field.
this is deemed a useful special case since journalctl will only show
either the first or last element of the message array if the field
appears multiple times.

Based on patch from: Kjetil Torgrim Homme <kjetil.homme@redpill-linpro.com>
https://github.com/karelzak/util-linux/pull/743

Addresses: https://github.com/karelzak/util-linux/issues/742
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-23 11:41:43 +01:00
Karel Zak 9ed2117897 whereis: search in /(s)bin before /usr/lib
Addresses: https://github.com/karelzak/util-linux/issues/741
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-17 11:19:27 +01:00
Karel Zak 969e8cbeb1 libblkid: improve whole-disk detection when read /proc/partitions
blkid(8) in high-level mode checks partitions and unpartitioned
whole-disk devices from the file /proc/partitions.

The current heuristic assumes that partition name ends with a digit.
Unfortunately, this is not correct -- for example md0 or nvme0n1 are
whole-disk devices.

This commit uses sysfs_devno_is_wholedisk() to make sure the device is
a partition (according to kernel or DM). It's probably more expensive,
because this way requires more syscalls (to read stuff from /sys etc.).

The patch also adds more information to the blkid(8) man page.

Addresses: https://github.com/karelzak/util-linux/issues/728
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-01-08 12:07:18 +01:00
Sami Kerola e361253e88
lsblk: fix null pointer dereferences
Both catched with -Wnull-dereference compiler option:

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-12-10 20:25:58 +00:00
Karel Zak 0bd05f5ee4 lsblk: add --merge
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:57:49 +01:00
Karel Zak 0986f29a3f lsblk: make devtree dependences more generic
We also need reference from child to parent to implement multi-parent
view. This change allows to walk on tree in both directions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak dc4662f0e7 lsblk: add --dedup <column>
The target use-case are systems with large number of multi-path
devices or systems with duplicate (copied) filesystems.

The feature is flexible enough to use arbitrary column (for example
WWM or UUID, ...) as de-duplication key.

For example tree with multi-path devices sd{c,d,e,f}

./lsblk
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdd           8:48   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sde           8:64   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part
sdf           8:80   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

De-duplicate by WWN:

./lsblk -M WWN
NAME        MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda           8:0    0 223.6G  0 disk
├─sda1        8:1    0   200M  0 part  /boot/efi
├─sda2        8:2    0   200M  0 part  /boot
├─sda3        8:3    0 130.3G  0 part
├─sda4        8:4    0    50G  0 part  /
└─sda5        8:5    0  42.9G  0 part
sdb           8:16   0  74.5G  0 disk
└─sdb1        8:17   0  74.5G  0 part  /home/archive
sdc           8:32   0   100M  0 disk
└─mpatha    253:0    0   100M  0 mpath
  ├─mpatha1 253:1    0    50M  0 part
  └─mpatha2 253:2    0    49M  0 part

Addresses: https://github.com/karelzak/util-linux/issues/616
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak 10501add02 lsblk: remember whole-disk, remove unused struct member
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:33:34 +01:00
Karel Zak d81e32bde9 lsblk: make device_get_data() more generic
* independent on smartcols line
* keep sort data optional

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 57a061339b lsblk: apply --nodeps to partitions too
The new implementation differentiates between partitions and another
dependences -- this is regression, we need root devices only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 8a2f175cbb lsblk: read queue/discard_granularity only when necessary
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak 81a8936c56 lsblk: reuse 'removable' flag from parent
It's used in the default output, let's make it a little bit more
effective.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak ff7992d631 lsblk: don't keep sysfs dirs open
Don't keep open sysfs file descriptors for all time to avoid problems
on systems with huge number of block devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak b158bd29de lsblk: rename set_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak b93585e8fc lsblk: add comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak e7b5353e8b lsblk: add process_all_devices_inverse()
This is necessary to implement --inverse. Note that this new
implementation scans /sys/dev/block/ to get top-level devices
and than it calls process_one_device().

Note that standard non-inverse tree does not use process_one_device()
as it's more effective to scan /sys/block where are no partitions.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:58 +01:00
Karel Zak e15c9e3dc5 lsblk: reorder functions
The goal is to call process_one_device() from process_all_devices(),
so let's it keep in code in the right order.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak cf3c1bc77a lsblk: make process_partitions() more readable
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 0e086f8230 lsblk: remove unncessary parent pointer
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak ae4c2c375b lsblk: use real rather than hardcoded parent
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 4ca3c472f3 lsblk: use devtree functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak e2d7870b00 lsblk: add lsblk_device_has_dependence()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 291606faf9 lsblk: process_one_device() refactoring
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 583b6489f6 lsblk: add devtree_get_device_or_new()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 97c89dff13 lsblk: keep functions names consistent
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 9b4c648612 lsblk: remove unused reset_device()
Now all is maintained by reference counting ion the devtree.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 57502dd34c lsblk: fix devtree deallocation
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak f43b829759 lsblk: split sysfs reading and scols table filling
This change allows read devices from sysfs only once and reuse device
properties if the device is references more than once in the tree
(RAIDs, etc.).

* every device is in the tree only once (tree->devices list)

* iterate_block_devices() reuse already read devices (for example if
  already read for any dependence)

* the smartscols table is build from the final tree

The patch temporary disables dependencies evaluation (in
process_blkdev() to keep the patch small and simple.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 21d4a48c9c lsblk: cleanup device reference in the tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 3bf2a36cc5 lsblk: remove badly named debug interface name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 5bb395f4f6 lsblk: add basic function to build devices tree
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak a0a76f4265 lsblk: properly initialize structs
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 7cd9de40fa lsblk: rename reset_lsblk_device() to reset_device()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak fed34a1e63 lsblk: rename blkdev_cxt to lsblk_device
The patch does not change code logic and semantic -- just rename.

* set_cxt() to set_device()
* struct blkdev_cxt to lsblk_device

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-07 12:32:57 +01:00
Karel Zak 6df5acf970 lib/timer: add fallback if timer_create() not available
* add struct ul_timer as API abstraction to hide differences between
timer_create() and setitimer()

* add setitimer() detection to ./configure.ac

* add fallback code to use setitimer() if timer_create() not available
  (for example on OSX)

Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-12-03 11:23:33 +01:00
Karel Zak 0ab0817917 blkid: fix usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 13:30:11 +01:00
Karel Zak 5e91d5dd71 blkid: make PART_ENTRY_* tags optional (add --no-part-details)
blkid(8) returns information from partition table also for empty
partitions. This is necessary for example for udev, but it could be
confusing if you care about on-device content only.

Default:
 # blkid -p /dev/md0p1; echo $?
 /dev/md0p1: PART_ENTRY_SCHEME="dos" PART_ENTRY_UUID="6d8796b1-01" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="1" PART_ENTRY_OFFSET="2048" PART_ENTRY_SIZE="204800" PART_ENTRY_DISK="9:0"
 0

With --no-part-details:
 # blkid -p /dev/md0p1 --no-part-details; echo $?
 2

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1653413
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-11-29 13:21:36 +01:00
Andreas Henriksson df8d991b24 uuidd: Add hardening settings to uuidd.service
This limits what the uuid daemon has access to when it runs.

Further improving this with additional option or making
things even tighter is most likely possible.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2018-11-29 10:37:08 +01:00
Andreas Henriksson c8d61f361c uuidd: Add Documentation key to uuidd.service 2018-11-21 10:47:31 +01:00
Ruediger Meier 7d50d36121 hardlink: util-linux usage
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:14 +01:00
Ruediger Meier 53071734aa hardlink: fix compiler warnings
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-14 00:37:04 +01:00
Ruediger Meier 55c000e1eb hardlink: style indentations and license header
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:44:39 +01:00
Ruediger Meier 04ae85a7e5 hardlink: enable build with and without pcre2
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-11-12 19:40:33 +01:00
Patrick Steinhardt d2523d3dd2 rename: avoid undefined function prototype for `fpurge`
In case where the non-standard `fpurge` function is available, we
redefine `__fpurge` to `fpurge`. We can do so because the only
difference between both functions is that one returns an error code
while the other does not. But as we do not check the error code either
way, we do not care about which one of them we use.

The above redefinition happens unconditionally if we know that `fpurge`
exists. Most notably, we also redefine it if we already do have an
`__fpurge` function available that could be used. This causes problems
on musl-based platforms, where we detect availability of `fpurge` in
libc, but where no function declaration for it exists in "stdio_ext.h".
The compiler thus prints a warning due to an unknown function, even
though it will link just fine.

Avoid this warning by only redefining `__fpurge` to `fpurge` when
HAVE___FPURGE is not defined.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-10-04 11:56:37 +02:00
Patrick Steinhardt 6529212d5b lsblk: fix unknown type `stat` caused by missing header
The structure `blkdev_cxt` has a `struct stat` member embedded, whose
size may not be known on some systems because of a missing include for
"sys/stat.h". On glibc-based systems, this header is included
transitively via "sys/statvfs.h", but on musl-based systems it is not.

Fix the resulting compile error due to unknown size of the struct by
including "sys/stat.h".

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2018-10-04 11:56:35 +02:00
Karel Zak ef2ce68b1f lsblk: always use "part" as TYPE for partitions
The current code uses "part" or "disk" only if nothing else is
possible to recognize. It means for example partitions on loops (or
RAIDs, etc) are marked as "loop" rather than "part".

Addresses: https://github.com/karelzak/util-linux/issues/700
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-10-03 14:39:57 +02:00
Karel Zak ccafadb7c5 lsblk: move udev and blkid stuff to lsblk-properties.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19 11:40:17 +02:00
Karel Zak baad6dcc6e lsblk: cleanup udev/blkid properties code
* split properties to separate struct which is allocated only when
  udev or blkid provides some information

* use separate function for udev and blkid and hide details in generic
  get_device_properties()

* make sure we do not overwrite stuff udev and blkid (but this is only
  theoretic issue as we do not call get_properties_by_blkid() directly
  from code)

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-19 11:40:17 +02:00
Karel Zak 652cb1cd26 lsblk: encapsulate stat() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 16:27:26 +02:00
Karel Zak 82dae67d1a lsblk: differentiate between swap and mount
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:57:45 +02:00
Karel Zak 04be258d65 lsblk: use lsblk_ prefix mountpoint getter
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:49:00 +02:00
Karel Zak e0c016f11b lsblk: init/deinit libmount stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:45:53 +02:00
Karel Zak cfb715ed1d lsblk: move mount stuff to lsblk-mnt.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:41:39 +02:00
Karel Zak 14560b7f54 lsblk: add lsblk.h
* move core struct to the header file
* move debug stuff to the header file

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-14 15:36:59 +02:00
Karel Zak bc405d641e lsblk: add columns FSAVAIL,FSSIZE,FSUSED,FSUSE%
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-13 12:11:06 +02:00
Karel Zak 137599ebe1 lsblk: don't ask udev when --sysroot specified
We use --sysroot to get information about block devices from /proc and
/sys dumps. In this case does not make sense to read anything from
udev as udevd is about the current system devices.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-11 09:53:18 +02:00
Karel Zak 13cbc6f21c lsblk: prefer MODEL from udev DB
sysfs device model is truncated to 16 characters:

> cat /sys/block/sda/device/model
Crucial_CT128MX1
> udevadm info --query=property /dev/sda | grep MODEL=
ID_MODEL=Crucial_CT128MX100SSD1

sysfs uses INQUARY response which has the 16 characters limitation and
udev uses something else.

Addresses: https://github.com/karelzak/util-linux/issues/690
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-09-10 10:31:17 +02:00
Karel Zak 1b0a420281 Merge branch 'spelling' of https://github.com/jwilk-forks/util-linux
* 'spelling' of https://github.com/jwilk-forks/util-linux:
  Fix man page typos
2018-08-16 13:47:51 +02:00
Jakub Wilk b9c3b903fe Fix man page typos
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 11:09:15 +02:00
Jakub Wilk 456bda924f fincore.1: add missing space
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-08-16 10:37:10 +02:00
Karel Zak 1f6583930b logger: add -S to the man page
Reported-by: Radka Skvarilova <rskvaril@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-10 16:55:14 +02:00
Karel Zak 2395f93c8c cal: fix --span for large numbers of months
The need to calculate with whole years when go back for --span.

Addresses: https://github.com/karelzak/util-linux/issues/677
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-07 10:52:33 +02:00
Karel Zak 100a140688 cal: use snprintf everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-08-07 10:15:42 +02:00
Bjarni Ingi Gislason 62aa3f0eaf man pages: fix formatting of long lines in tables
Define the allowed length of the last (second) column to use the
whole line for text.

  Use text blocks for long lines.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-08-06 08:58:57 +02:00
Bjarni Ingi Gislason 934a6fa80b man pages: Remove "left" (or change to "l") in the column formats of tables
A developmental version of "groff" issued a warning, for example with
"test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z":

troff: <logger.1>:299: warning: can't find font 't'

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-08-06 08:58:57 +02:00
Karel Zak e736434bc8 blkid: fix compiler warnings [-Wcast-qual]
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-23 12:30:37 +02:00
Karel Zak 881953d735 lsblk: add note about --list -I <maj,...>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-18 16:21:01 +02:00
Karel Zak 66638b0b70 lsblk: add PATH column
$ lsblk -o+PATH
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT    PATH
sda           8:0    0 223.6G  0 disk               /dev/sda
├─sda1        8:1    0   200M  0 part /boot/efi     /dev/sda1
├─sda2        8:2    0   200M  0 part /boot         /dev/sda2
├─sda3        8:3    0 130.3G  0 part               /dev/sda3
├─sda4        8:4    0    50G  0 part /             /dev/sda4
├─sda5        8:5    0  35.1G  0 part               /dev/sda5
└─sda6        8:6    0   7.8G  0 part               /dev/sda6

Requested-by: Marcel Partap <mpartap@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-07-10 10:33:18 +02:00
YmrDtnJu 03190b73f0
logger: Define SD_JOURNAL_SUPPRESS_LOCATION.
The normal journald functions add the location in the C source code files to
the log messages. This is nice for a big C based project, but logger is used in
scripts so it would be more useful to let users specify the location in the
script by adding the CODE_FUNC, CODE_FILE and CODE_FILE fields to the log
message.

It is already possible to do this, but it will result in two versions of these
fields: one for the location in logger.c and one for the location in the
script.
2018-07-07 20:11:46 +02:00
Ruediger Meier 3097f788f9 wipefs: add missing ifdef
Seen on OSX:
misc-utils/wipefs.c:822:5: warning: implicit declaration of function 'rereadpt' is invalid in C99 [-Wimplicit-function-declaration]
                                rereadpt(fd, devname);

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-06-25 16:49:54 +02:00
Karel Zak 905bc7817e lsblk: fix ul_path_read_string() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak bd45b74fc9 lsblk: fix COL_SCHED
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 498d148661 lsblk: document --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 3273ce07e3 lsblk: fix sysfs_devno_to_devname() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak caf1b443c0 lsblk: follow --sysroot when read mountpoints
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak 5a89aa99a7 lsblk: use prefix for DM name
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak ffc2762393 lsblk: add --sysroot
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Karel Zak f153614c57 lsblk: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:19:28 +02:00
Milan Broz 1b06b33dd0 lsblk: add partition table UUID and type fields.
This patch adds PTUUID and PTTYPE fields to lsblk, that are corresponding
fields to ID_PART_TABLE_UUID and ID_PART_TABLE_TYPE in udev database.

[kzak@redhat.com: - small change in PTUUID description]

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-19 17:05:42 +02:00
Ruediger Meier f385180ab3 Merge branch 'hardlink-import' into hardlink
Import hardlink source and manpage version 1.3 from
https://pagure.io/hardlink.git
revision 24da8615f7a9c67648bfe9b6709ba7786d61b89a
2018-06-12 14:26:25 +02:00
Kevin Fenzi 5aad3c12f3 fixes for the fixes
Signed-off-by: Francisco Javier Tsao Santín <tsao@gpul.org>
2018-06-12 14:24:15 +02:00
Francisco Javier Tsao Santín 3b94989389 temporal fix before re-patch (updates from Fedora repo) 2018-06-12 14:24:11 +02:00
utoddl 88824694f6 Update hardlink.1
The example regex in the BUGS section needs its backslashes backslashed.
2018-06-12 14:24:07 +02:00
Francisco Javier Tsao Santín c64d7e60b1 Fixed version number, added changelog about Todd Lewis' patch 2018-06-12 14:24:04 +02:00
Todd Lewis 551e8963f4 exclude files via pcre 2018-06-12 14:24:02 +02:00
Francisco Javier Tsao Santín 92c79dc79e Fixed 32 bit build with gcc7 (RH Bugzilla ID 1422989) 2018-06-12 14:23:57 +02:00
Francisco Javier Tsao Santín 4d072ba715 spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); update FSF address at .c source file 2018-06-12 14:23:55 +02:00
Francisco Javier Tsao Santín cbb0524c7c Revert "spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file"
This reverts commit bb9e76ae339794c2243ae294207942b7ea278364.
2018-06-12 14:23:52 +02:00
Francisco Javier Tsao Santín c11af66f0f spec file reflects the atomic hardlinking patch; removed cleaning buildroot (redundant); current FSF address at .c source file 2018-06-12 14:23:49 +02:00
Jan Zeleny 348af99a62 Mention -f option in the man page 2018-06-12 14:23:47 +02:00
Jindrich Novy c23b4a2305 do not allow to hardlink files across filesystems by default (#786719)
(use -f option to override)
2018-06-12 14:23:44 +02:00
Jindrich Novy 94b040b06b fix possible buffer overflows, integer overflows, update man page 2018-06-12 14:23:41 +02:00
Jindrich Novy 0cd6b1d353 fix URL and remove mmap() (#676962, #672917) 2018-06-12 14:23:38 +02:00
Jindrich Novy a272f143e7 - update docs to describe highest verbosity -vv option (#210816)
- use dist Resolves: 210816
2018-06-12 14:23:35 +02:00
Jindrich Novy b4ece7768f mostly spec cleanup 2018-06-12 14:23:31 +02:00
Jindrich Novy cabf1c1cb7 add -h option 2018-06-12 14:23:25 +02:00
Dave Jones a810992a72 Document hardlink command line options. (Ville Skytta) (#161738) 2018-06-12 14:23:03 +02:00
Jeremy Katz a16d7294a8 - don't try to hardlink 0 byte files (#154404) 2018-06-12 14:22:59 +02:00
Dave Jones 5edefc9242 kill warning 2018-06-12 14:22:54 +02:00
Dave Jones 0ec20db824 auto-import hardlink-1.0-1.1 on branch devel from hardlink-1.0-1.1.src.rpm 2018-06-12 14:22:47 +02:00
Karel Zak 921f63433e wipefs: postpone BLKRRPART until all is done
It's possible we erase from the whole device before we erase from the
partition on the same disk:

 # wipefs -a /dev/sdc /dev/sdc1

the current code calls re-read PT ioctl immediately after erase (so,
before sdc1 is processed). The result is that sdc1 node is no more
accessible:

  # wipefs -a /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc: calling ioctl to re-read partition table: Success
  wipefs: error: /dev/sdc1: probing initialization failed: No such file or directory

It seems the most simple solution is to postpone the re-read ioctl and
do it as the last thing.

  # wipefs -a  /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc1: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef
  /dev/sdc: calling ioctl to re-read partition table: Success

The patch also adds a small delay before the re-read ioctl call. It's
not elegant, but without the usleep(25000) the first attempt returns
EBUSY.

Addresses: https://github.com/karelzak/util-linux/issues/598
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 12:36:32 +02:00
Sami Kerola 1405658822 nls: remove translation strings
While looking earlier commit I noticed everything but formatting was removed
from a message in namei.c file.  That inspired me to look if there are more
strings that does not need translation project attention.  This change
removes at least some of them, if not all.

Reference: e19cc7b65b
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-28 13:36:38 +02:00
Bjarni Ingi Gislason 3fe5e8ec09 man: Change the only argument to two for the two-fonts macros
Punctuation marks have been left in the only argument of two-fonts
macros, instead of being separated from it to make the second one.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Bjarni Ingi Gislason 0bb7e904d7 man: Use the correct macro for a font change of one argument
Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2018-05-23 10:43:27 +02:00
Karel Zak 3d15a5e852 lsblk: fix notes about RAM disks
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15 10:51:15 +02:00
Karel Zak b9dd5721fc lsblk: don't exclude RAM disks on --all
Reported-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-05-15 10:29:22 +02:00
sluidfoe 0bff4e134e misc-utils/findmnt.8: add --pseudo and --real options 2018-05-10 11:58:31 -05:00
sluidfoe f920bfd5a8 misc-tools/findmnt: a few whitespace fixes 2018-05-10 11:58:31 -05:00
sluidfoe 4c856a471e misc-tools/findmnt: add --pseudo, --real filters 2018-05-10 11:58:30 -05:00
Sami Kerola 25d3c40534
lslocks: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:20 +01:00
Sami Kerola 00147883de
findmnt: add --output-all option
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-05-03 19:56:20 +01:00
Karel Zak fc402b8b71 blkid: (man) add note about udev encoding
Addresses: https://github.com/karelzak/util-linux/issues/632
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-30 10:53:04 +02:00
Karel Zak a3571e1b97 wipefs: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:12:46 +02:00
Karel Zak fffdff1e61 lslocks: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:07:31 +02:00
Karel Zak 51b0bcf01d lslocks: add --bytes cleanup SIZE usage
The new command line option --bytes disables human readable output for
the SIZE and keep size in bytes. We use the same concept for all our
utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 15:01:31 +02:00
Karel Zak 3a645e3658 findmnt: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 14:45:21 +02:00
Karel Zak 8945d9dc63 fincore: use scols_column_set_json_type()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-18 14:32:39 +02:00
Karel Zak d14c1c39dd Merge branch 'rename-interactive' of https://github.com/g-raud/util-linux
* 'rename-interactive' of https://github.com/g-raud/util-linux:
  rename: fixup & style (no functional changes)
  rename: test availability of __fpurge() and fpurge()
  rename: ask(): call __fpurge() to cater for multi-byte characters
  rename.1: describe interactive mode
  rename: ask(): print n when EOF on input
  rename: detect tty in cbreak mode to make ask() read a single byte
  rename.1: fix warning section
  rename: add option --interactive to ask before overwriting
  rename: skip faccessat() failure if AT_SYMLINK_NOFOLLOW is not a valid flag
  rename: check source file access early
2018-04-16 10:37:31 +02:00
Karel Zak 6ceb17c8a7 lslocks: fix memory leak
Addresses: https://github.com/karelzak/util-linux/pull/618
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-16 10:27:29 +02:00
Karel Zak 2aaf56c45f lslocks: add info about OFD
It seems users are confused by PID -1 and missing path. This patch add
more information about OFD locks to the man page and "undefined" to
the COMMAND column.

References: http://austingroupbugs.net/view.php?id=768
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1527102
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-13 11:22:21 +02:00
G.raud Meyer 7ac394f84b rename: fixup & style (no functional changes) 2018-04-09 17:21:17 +02:00
G.raud Meyer 0dba6b6f19 rename: test availability of __fpurge() and fpurge() 2018-04-09 17:21:17 +02:00
G.raud Meyer 33785dd33c rename: ask(): call __fpurge() to cater for multi-byte characters
Making a purge in cbreak mode also makes the code compatible with
canonical mode.  This can be useful in the case a shell, like bash, does
not restore the tty state of stopped jobs before restarting them.  An
alternative fix to this minor shortcoming would be to retest the tty
state each time inside ask().
2018-04-09 17:21:17 +02:00
G.raud Meyer 16740b0c7a rename.1: describe interactive mode 2018-04-09 17:21:16 +02:00
G.raud Meyer 0cb2c653c3 rename: ask(): print n when EOF on input 2018-04-09 17:21:16 +02:00
G.raud Meyer f43bdedaa7 rename: detect tty in cbreak mode to make ask() read a single byte
Set tty_cbreak only when tty has a VMIN of 1 to avoid having to purge at
all in cbreak mode.

The prompt is still compatible with a non interactive input from a pipe.
2018-04-09 17:21:16 +02:00
G.raud Meyer 961b094629 rename.1: fix warning section 2018-04-09 17:21:16 +02:00
G.raud Meyer eb4aea8a47 rename: add option --interactive to ask before overwriting
The option name -i/--interactive is picked from mv(1) and cp(1) from GNU
and BSD.

Also update the manpage.
2018-04-09 16:05:44 +02:00
G.raud Meyer 826538bf64 rename: skip faccessat() failure if AT_SYMLINK_NOFOLLOW is not a valid flag
AT_SYMLINK_NOFOLLOW is not required by POSIX and it is not a valid flag
on Mac OSX.
2018-04-09 15:41:30 +02:00
G.raud Meyer 5454df9c31 rename: check source file access early
This change makes rename detect inexisting files given on the command
line and consider them faliures.  This is particularly useful with
--no-act (to detect extraneous arguments).

It also prevents skipping non existing files (when the modified name
happens to exist).  This makes --verbose not print skipping messages of
false positives (the access error is printed instead).
2018-04-09 14:37:56 +02:00
Karel Zak e4c58e00a0 Merge branch 'rename-fix-noact-without-nooverwrite' of https://github.com/g-raud/util-linux
* 'rename-fix-noact-without-nooverwrite' of https://github.com/g-raud/util-linux:
  rename: prevent --no-act from setting --no-overwrite
  rename: when --no-overwrite skip verbosily only when --verbose
  rename: consolidate printing the symlink in addition to its target
  rename: fix/reverse the semantics of --no-overwrite in --symlink mode
2018-04-09 11:46:22 +02:00
Bjarni Ingi Gislason ac5ebb8cb8 misc-utils/getopt.1: minor corrections to the manual
Input file is getopt.1

Test nr. 2:

Enable and fix warnings from 'test-groff'.

Input file is /tmp/getopt.1

<getopt.1>:5 (macro BI): only 1 argument, but more are expected
<getopt.1>:419 (macro IR): only 1 argument, but more are expected
<getopt.1>:421 (macro IR): only 1 argument, but more are expected

chk_manuals: Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

  and

Test nr. 15:

Change the name of a macro for two fonts (e.g., BR and IR) to one letter,
if there is only one argument.
Add the second argument if needed.  It is sometimes part of the first one.

5:.BI getopt
419:.IR /usr/share/getopt/
421:.IR /usr/share/doc/

#####

Test nr. 8:

Protect a full stop (.) with "\&", if it has a blank (white-space) in front
of or (ignoring transparent characters to the full stop) after it, and it does
not mean an end of a sentence.

204:the next parameter (i.e. separated by whitespace on the command
219:or as the next argument (i.e. separated by whitespace on the command
352:(i.e. a parameter that does not start with a
379:will be parsed.  It will still do parameter shuffling (i.e. all

#####

Test nr. 20:

Use a macro to change to the italic font, instead of \fI [1], if
possible.
The macros have the italic corrections, but "\c" removes them.
[1] man-pages(7)

57:is set, or if the first \fIparameter\fR is not an option (does not start
144:Set quoting conventions to those of \fIshell\fR.

#####

Test nr. 21:

Use the word (in)valid instead of (il)legal if not related to legal matters.
See "www.gnu.org/prep/standards".

25:check for legal options.  It uses the

#####

Test nr. 28:

Wrong distance between sentences or protect the indicator.

1) Separate the sentences and subordinate clauses; each begins on a new
line.  See man-pages(7) and "info groff".

Or

2) Adjust space between sentences (two spaces),

3) or protect the indicator by adding "\&" after it.

The "indicator" is an "end-of-sentence character" (.!?).

204:the next parameter (i.e. separated by whitespace on the command
219:or as the next argument (i.e. separated by whitespace on the command
352:(i.e. a parameter that does not start with a
379:will be parsed.  It will still do parameter shuffling (i.e. all
Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>

#####
2018-04-06 13:10:23 +02:00
Karel Zak 407e0ea619 lsblk: consolidate column types for JSON and qsort()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-04-03 15:10:21 +02:00
G.raud Meyer 0849ff3660 rename: prevent --no-act from setting --no-overwrite
This fixes a bug introduced by commit fabb90676 ("Added --no-override
option to rename.", 2017-05-27) where the fallthrough meant to let
--no-act set --verbose was changed to set --no-override (the previous
code was too smart).

Do not let --no-act set --verbose anymore but update the manual to
recommend adding option --verbose.  This is to be able to make --no-act
detect only non existing file arguments (in a future commit).
2018-03-29 20:35:30 +02:00
G.raud Meyer 6277e2310e rename: when --no-overwrite skip verbosily only when --verbose 2018-03-27 15:22:58 +02:00
G.raud Meyer b98ab3032d rename: consolidate printing the symlink in addition to its target 2018-03-27 14:49:52 +02:00
G.raud Meyer 5bb927006f rename: fix/reverse the semantics of --no-overwrite in --symlink mode
The previous behaviour was to overwrite a symlink only when the new
destination did not exist, i.e. to avoid creating a symlink to an
existing file!  It had not been documented and it seems
counter-intuitive to me.  So the new behavior protects symlinks pointing
to existing targets from being changed.

Also update manpage to document this mode.
2018-03-27 14:48:00 +02:00
Karel Zak e19cc7b65b namei: provide more usable error message on lstat() error
Addresses: https://github.com/karelzak/util-linux/issues/608
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-27 13:30:16 +02:00
Karel Zak 04060bc3f1 Merge branch 'master' of https://github.com/pali/util-linux
* 'master' of https://github.com/pali/util-linux:
  tests: Add tests for FAT32 labels
  blkid: Encode any field which starts with LABEL in same way as LABEL field
  libblkid: vfat: Change parsing label in special cases
2018-03-27 12:54:53 +02:00
Karel Zak 655776a2c1 mcookie: (man) add note about getrandom()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-19 14:03:33 +01:00
Karel Zak 2446d0487f uuidd: cosmetic coding style change
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-07 11:53:15 +01:00
Ruediger Meier eb10dbc159 uuidd: don't truncate long socket paths
This was the error
  uuidd: couldn't bind unix socket /var/tmp/portage/sys-apps/util-linux-2.31.1/work/util-linux-2.31.1-abi_x86_64.amd64/tests/output/uuid/uuiddkOcTUuoZ7kaP3: Address already in use

because the socket path was truncated to 108 chars which was luckily
an existing directory.

Now we abort early with "uuidd: socket name too long: ... "

Reported-by: Thomas Deutschmann <whissi@gentoo.org>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-03-07 11:50:05 +01:00
Tobias Stoeckmann fcfe1a5cde fincore: Handle large files on 32 bit without LFS
If util-linux is installed on a system without large file support,
an out of memory issue can occur while processing a file which is
2 GB in size:

$ ./configure --disable-largefile && make

$ dd if=/dev/zero of=2gb-file seek=2147483646 count=1 bs=1
$ fincore 2gb-file
(endless loop)
fincore: failed to do mmap: 2gb-file: Cannot allocate memory

Even though iterating with "len" seems counter-intuitive, it fixes
this issue. The variable len is only in the last iteration not a
multiplication of pagesize -- which is the requirement for mmap.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-02-26 11:54:12 +01:00
Tobias Stoeckmann ea62c15276 fincore: Handle large files correctly on 32 bit
If a file is larger than 4 GB on a 32 bit system with large file
support (default), it can happen that not all pages are properly
processed. This happens due to an int truncation (off_t vs size_t).

You can reproduce this on 32 bit with these commands:

$ dd if=/dev/zero of=4gb-file seek=4294967295 count=1 bs=1
$ fincore 4gb-file
fincore: failed to do mmap: 4gb-file: Invalid argument

If a file is larger than 4 GB, the first few pages of a file won't
be properly processed. "len" will be smaller than window_size,
but the for-loop iterates "window_size" bytes, skipping some pages.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2018-02-26 11:54:12 +01:00
Karel Zak 3476084d14 lsblk: document LSBLK_DEBUG=
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-16 19:10:35 +01:00
Ruediger Meier 73afd3f8e8 misc: fix typos using codespell
Some more funny typos, please review carefully.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2018-02-16 11:12:52 +01:00
Karel Zak a31bb9b6a1 cal: clean up man page synopsis syntax
Let's use '[ ]' rather than '< >' to be compatible with our another
man pages. Note that all time addressing on cal(1) command line is
optional.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1542883
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-07 11:19:44 +01:00
Jakub Wilk f04c77f0a3 findmnt.8: remove spurious spaces before "--tree" and "--verbose"
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2018-02-04 19:31:17 +01:00
Karel Zak b9d9ab7dae cal: add ifdef TEST_CAL
The test program follows CAL_TEST_TIME=<sec> rather than libc time().
It allows to use cal(1) in regression tests in cases where output
depends on the current time.

(We already use the same for example for logger.)

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-02 10:05:15 +01:00
Karel Zak 79d6aa3811 findfs: don't include exitcodes.h
The code uses findfs return codes only.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-02-01 14:51:55 +01:00
Karel Zak f066c107ce cal: remove extra space after year output
Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:17:10 +01:00
Karel Zak 37bd991f77 cal: don't use year header for -1, -3 or -n
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:14:15 +01:00
Karel Zak 8315a2ff15 cal: follow terminal width
* modify number of months in row according to the terminal width
* don't print blank space behind last char on row

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-30 16:10:06 +01:00
J William Piggott d7db28c6d6 cal: do not set months_in_row with -3 option
Having the -3 option set months_in_row causes ordinal days
to wrap; it overrides the automatic handling of months_in_row
that falls back to 2 month columns for ordinal days.

Before:
cal -3j 2020
                           2020

            July                         August                      September
Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat
    182 183 184 185 186 187                   213 214 215   244 245 246 247 248 249 250
188 189 190 191 192 193 194   216 217 218 219 220 221 222   251 252 253 254 255 256 257
195 196 197 198 199 200 201   223 224 225 226 227 228 229   258 259 260 261 262 263 264
202 203 204 205 206 207 208   230 231 232 233 234 235 236   265 266 267 268 269 270 271
209 210 211 212               237 238 239 240 241 242 243   272 273

Patched:
cal -3j 2020
                           2020

          December                      January
Sun Mon Tue Wed Thu Fri Sat   Sun Mon Tue Wed Thu Fri Sat
335 336 337 338 339 340 341                 1   2   3   4
342 343 344 345 346 347 348     5   6   7   8   9  10  11
349 350 351 352 353 354 355    12  13  14  15  16  17  18
356 357 358 359 360 361 362    19  20  21  22  23  24  25
363 364 365                    26  27  28  29  30  31

          February
Sun Mon Tue Wed Thu Fri Sat
                         32
 33  34  35  36  37  38  39
 40  41  42  43  44  45  46
 47  48  49  50  51  52  53
 54  55  56  57  58  59  60

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-24 13:24:33 +01:00
J William Piggott 2bcf8f7934 cal: honor num_months when only a year argument
I don't know if this was an oversight or an overzealous
interpretation of POSIX. Just in case, I'll address the
POSIX possibility. POSIX description for cal(1) says:

  If only the year operand is given, cal shall produce a
  calendar for all twelve months in the given calendar year.

It also says that cal(1) has no options, so in that context
if an option is given then it should be expected to override
POSIX behavior.

Before patched all of these command displayed a full year:
cal -1 2020
cal -3 2020
cal -n6 2020

Patched the number of months options are honored.

This patch also fixes the -1 option which was a no-op.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-24 13:24:33 +01:00
J William Piggott 6304358cb7 cal: fix first week calculation
Commit efafeaf set 1 Jan as week 1, but the change
was missed in week_to_day() and in the man page.

Before
cal --week=40 --iso 1752
      October 1752
   Su Mo Tu We Th Fr Sa
41  1  2  3  4  5  6  7
42  8  9 10 11 12 13 14
43 15 16 17 18 19 20 21
44 22 23 24 25 26 27 28
45 29 30 31

Patched
cal --week=40 --iso 1752
     September 1752
   Su Mo Tu We Th Fr Sa
36                 1  2
37  3  4  5  6  7  8  9
38 10 11 12 13 14 15 16
39 17 18 19 20 21 22 23
40 24 25 26 27 28 29 30

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 14:16:57 +01:00
J William Piggott e572a765f9 cal: fix week calculations for 1752
Before:
cal --week=39 1752
     September 1752
   Su Mo Tu We Th Fr Sa
36        1  2 14 15 16
37 17 18 19 20 21 22 23
38 24 25 26 27 28 29 30

Patched:
cal --week=39 1752
      October 1752
   Su Mo Tu We Th Fr Sa
39  1  2  3  4  5  6  7
40  8  9 10 11 12 13 14
41 15 16 17 18 19 20 21
42 22 23 24 25 26 27 28
43 29 30 31

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 14:16:57 +01:00
Rafal Luzynski 4e12a62e88 cal: Use ALTMON_* correctly
cal: use ALTMON_* and _NL_ABALTMON_* constants to display
months in a standalone form correctly.  These constants have just
been newly added to glibc.  ALTMON_x has been used in BSD family
since 1990s and has been accepted as the future POSIX extension.
_NL_ABALTMON_* is exclusively a GNU extension but it is expected
to be added to POSIX in future.

More info: https://sourceware.org/bugzilla/show_bug.cgi?id=10871
2018-01-22 11:50:50 +01:00
J William Piggott 1dca3edc36 cal: fix julian calendars for large years
Before:
cal --r julian 31 12 2147483646
 December 2147483646
Su Mo Tu We Th Fr Sa
 1  2  3  4  5  6  7
 8  9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Patched:
cal --r julian 31 12 2147483646
 December 2147483646
Su Mo Tu We Th Fr Sa
                   1
 2  3  4  5  6  7  8
 9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-22 11:33:20 +01:00
Karel Zak a15dca2f6d include/debug: introduce __UL_INIT_DEBUG_FROM_STRING()
Let's make it possible to use debug.h without environment variables.

Suggested-by: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-17 13:58:29 +01:00
J William Piggott a4b55ad008 cal: update man page
Update cal.1 with the new options --reform and --iso.

Also add information about the calendar systems used and
the difference between the --julian option and the Julian
calendar system.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-16 13:51:43 -05:00
J William Piggott ae51e7b429 cal: add option to set Gregorian reform date
Create the new option: --reform <1752|gregorian|iso|julian>

This adds the capability to display either the proleptic Gregorian or
the Julian calendar systems exclusively.

Also create the option --iso as alias of --reform=gregorian.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-16 13:51:24 -05:00
J William Piggott db9baa8ab7 cal: move REFORMATION_YEAR to control struct
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2018-01-15 11:06:36 -05:00
Karel Zak 6d00cfb233 include/debug: don't print pointer address for SUID programs
* introduce new flag __UL_DEBUG_FL_NOADDR to suppress pointer address printing

* use __UL_DEBUG_FL_NOADDR when SUID

* move ul_debugobj() to debugobj.h, and require UL_DEBUG_CURRENT_MASK
  to provide access to the current mask from ul_debugobj(). It's better
  than modify all ul_debugobj() calls and use the global mask as
  argument.

* remove never used UL_DEBUG_DEFINE_FLAG

Reported-by: halfdog <me@halfdog.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-01-12 11:01:26 +01:00
Kenyon Ralph deff4975a1
rename.1: fix typo, where -> were 2017-12-23 13:44:34 -08:00
Karel Zak 6ce7eca36c cal: fix multi-byte comment, explain in better way
On Sun, Dec 17, 2017 at 07:47:49PM -0500, J William Piggott wrote
> * it contains multi-byte characters (which is what drew me to reading it).
> * it truncates one very important piece of the formula: ". . . (mod 7)."
> * it explains the values for 'e', but there is no 'e' in the code.
> * it doesn't include a row resolving 'e' in the table, so it is not
>    obvious what it relates to in the code.
> * without citing it as an external reference, the comment language is confusing.

Co-Author: J William Piggott <elseifthen@gmx.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-18 12:44:03 +01:00
Karel Zak 7468a8d106 whereis: fix typo in debug message
Reported-by: Matthew White <mehw.is.me@inventati.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-14 15:52:57 +01:00
Karel Zak b9c650106b Revert "cal: simplify leap year rule"
It was mistake, we use extra rule for date < 1752 from the beginning
and another calculations depends on this.

This reverts commit b9bd8dc267.
2017-12-14 13:19:08 +01:00
Karel Zak 3c49b23ad6 cal: explain magic values for day of week calculation
Based on BERNDT E.SCHWERDTFEGER papers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-13 19:09:56 +01:00
Masatake YAMATO 616e75c02c fincore: fix a typo in fincore.1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-13 13:06:54 +01:00
Karel Zak 856d856a98 mcookie: properly initialize hash
This stupid mistake has been introduced by commit 46ae163a8e.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:09:13 +01:00
Karel Zak 42dea85c5a lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:06:15 +01:00
Sami Kerola 378d58abb1 rename: use access(3) to check if a file exists
This is more lightweight than calling stat(3).  In same go add a regression
test to ensure changes like this will not break --no-overwrite option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-04 13:04:12 +01:00
Sami Kerola bfcd327541 man: use long options in text and add example to uuidgen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:15 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Pali Rohár 0d2e8ff94d blkid: Encode any field which starts with LABEL in same way as LABEL field
This applies also for LABEL_FATBOOT which contains bytes according to DOS
code page and therefore does not contain valid UTF-8 sequence.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
2017-11-25 12:48:32 +01:00
Karel Zak 06a27566e1 lsblk: add hint about perms to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-22 12:31:58 +01:00
Karel Zak b9bd8dc267 cal: simplify leap year rule
Gregorian rule for leap years has been adopted by reformation in year
1782 (Calendar Act 1750), but all tools (date, SQL servers, etc. etc.)
don't care about it and apply the new rule for all year -- including
years before the reformation.

It's better to be compatible with another tools than try to be perfect :-)

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1507271
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-13 17:34:19 +01:00
J William Piggott 4111bb3ab5 lib/timeutils: add common ISO timestamp masks
* Start the ISO format flags at bit 0 instead of bit 1.

* Remove unnecessary _8601 from ISO format flag names to
  avoid line wrapping and to ease readability.

* ISO timestamps have date-time-timzone in common, so move
  the TIMEZONE flag to bit 2 causing all timestamp masks
  to have the first three bits set and the last four bits
  as timestamp 'options'.

* Change the 'SPACE' flag to a 'T' flag, because it makes
  the code and comments more concise.

* Add common ISO timestamp masks.

* Implement the ISO timestamp masks in all applicable code
  using the strxxx_iso() functions.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-11-10 16:34:55 -05:00
Karel Zak 4707bc83e1 lslocks: add note about OFDLCK
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-03 11:20:41 +01:00
Karel Zak c61e986fd0 lib/signames: remove signame array from header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-23 13:18:57 +02:00
Karel Zak c5910c7f27 Merge branch 'kill-child-feature' of https://github.com/nh2/util-linux
* 'kill-child-feature' of https://github.com/nh2/util-linux:
  unshare: Allow passing <signame> to --kill-child
  unshare: Add --kill-child option.
  signames: Make input char buffers const
  kill: Extract signal names into signames.h/signames.c
2017-10-23 12:58:21 +02:00
Karel Zak beaca64a6c blkid: improve man page wording
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 23:26:45 +02:00
Karel Zak 27fbfef33c blkid: more info about ambivalent results to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 12:01:41 +02:00
Karel Zak 12786a9015 blkid: cleanup man page info about lsblk
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-16 11:45:41 +02:00
Niklas Hambüchen 6855f6e80b kill: Extract signal names into signames.h/signames.c 2017-10-14 04:46:13 +02:00
Karel Zak 2d4c226dfb logger: keep header generators independent on connection
* avoid memory leaks
* don't use incomplete or header after free()

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 14:21:27 +02:00
Karel Zak 5794087292 fincore: make sure mmap(NULL, ...) [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-12 12:44:55 +02:00
Karel Zak e92d55e6cb logger: allow to reconnect on initial failed connect too
The current code sets noact flag if unix socked connection failed. This is ugly.
We want to reconnect always in all cases (well, except --socket-error=on).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-11 12:35:24 +02:00
Karel Zak 87ac63c9fa logger: add dummy fallback for OSX
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-10 14:45:55 +02:00
Karel Zak caf6ac6e59 logger: reconnect on failed send()
The libc syslog() reconnects on failed send(). We need the same thing
as logger(1) is expected as long time running tool. For example
recommended Apache configuration is:

	ErrorLog "| /usr/bin/logger -t apache_error -p local6.debug"

The issue is that connection endpoint (e.g. syslogd) maybe restarted.
The simple way how to test is:

	for i in $(seq 0 3600); do echo "This is message number $i"; sleep 1; done | logger --tcp --server 127.0.0.1 --port 514

and restart your syslog. The current implementation gets SIGPIPE or
write warning message, but it never reconnect.

Addresses: https://github.com/karelzak/util-linux/issues/363
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-10-10 13:56:30 +02:00
Karel Zak 774178f727 Merge branch 'patch-1' of https://github.com/aner-perez/util-linux 2017-09-15 14:45:36 +02:00
Karel Zak ae1c9d6008 uuidparse:fix stack-buffer-overflow [asan]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:30:45 +02:00
Karel Zak 9f20d80079 misc: cleanup UUID_STR_LEN definitions
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 13:25:32 +02:00
Karel Zak 8b318eb25e logger: make stdin parsing more friendly to static analyzers
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-15 12:54:54 +02:00
Aner Perez ed21c47aa1 Example for renaming foo? does not work as described
Command for renaming foo? should add 2 zeros to make all the file names have 3 digits as described in the example results.
2017-09-14 11:30:53 -04:00
Karel Zak e12364cdfb lsblk: small man page change in return codes description
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-07 10:03:18 +02:00
Karel Zak 3184afa529 uuidgen: add more details to man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-05 12:17:26 +02:00
Philip Prindeville c6f1ec68a8 uuidgen: add support for hash-based UUIDs
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:56:24 +02:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Karel Zak 0e45b256ac wipefs: cleanup offsets list usage, fix -t filter
* move list with offsets specified by -o to the wipe_control struct
* don't clone the list of offsets, just keep it simple and stupid
* apply all filters (-o and -t) in get_desc_for_probe()
* always return offset and len by get_desc_for_probe() and apply
  always use libblkid hide & step-back

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1486777
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-08-31 14:47:14 +02:00
Sami Kerola a653878c45 look: use WORDLIST environment variable to find word list
The WORDLIST is the same hunspell(1) and ispell(1) uses to achieve the same.
Apparently aspell(1) does not work with files like traditional dict lists.

Reference: https://github.com/hunspell/hunspell/blob/master/man/hunspell.1#L388
Reference: http://www.skrenta.com/rt/man/ispell.1.html
Reference: http://aspell.net/man-html/Creating-an-Individual-Word-List.html#Creating-an-Individual-Word-List
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-21 10:48:20 +02:00
Sami Kerola 8cfbd35048
uuidparse: nil uuid have all bits set to zero
The nil UUID is special form of UUID that is specified to have all 128 bits
set to zero.

Reference: https://tools.ietf.org/html/rfc4122#section-4.1.7
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-08-05 09:58:25 +01:00
Andreas Henriksson 8df545592d build: use --runstatedir instead of --localstatedir
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>
2017-07-31 15:24:46 +02:00
Andreas Henriksson c9ab738706 whereis: include native multiarch path in lib search paths
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>
2017-07-31 13:48:04 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Karel Zak 07fd6640c8 Merge branch 'path-fixes' of https://github.com/rudimeier/util-linux
* 'path-fixes' of https://github.com/rudimeier/util-linux:
  hwclock: don't ifdef printf arguments
  setpriv: align --help
  tools: add segfault detection for checkusage.sh
  misc: avoid some dead initialization warnings
  lscpu: make clang analyzer happy
  lsmem: fix, using freed memory
  lib/path: add error handling to path_vcreate()
  lib/path: fix crash, pathbuf overflow
2017-06-29 15:29:33 +02:00
Ruediger Meier c3ae785433 misc: avoid some dead initialization warnings
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>
2017-06-29 14:04:25 +02:00
Karel Zak 4c2af16845 uuidgen: improve --help
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 12:40:22 +02:00
Karel Zak 42d2a8b30d wipefs: improve --help
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 12:38:40 +02:00
Karel Zak d9921b2a12 wipefs: use libsmartcols
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>
2017-06-29 11:59:38 +02:00
Karel Zak e8fd8c6b9b uuidparse: se JSON table name on -J
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-29 11:07:54 +02:00
Karel Zak 2cd417ea71 wipefs: try another magic strings on -o and -t
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>
2017-06-28 12:08:25 +02:00
Karel Zak 4e60928139 wipefs: add control struct
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 11:51:12 +02:00
Karel Zak 193d6f27fb wipefs: don't do step-back if <type> does not match
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-28 10:28:41 +02:00
Karel Zak 92296e9ba2 wipefs: print all signature permutations
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>
2017-06-28 10:28:41 +02:00
Karel Zak b899fd87bd Merge branch 'help-description' of https://github.com/rudimeier/util-linux
* '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
2017-06-27 14:14:14 +02:00
Ruediger Meier b305445495 misc: consolidate all --help option descriptions
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>
2017-06-27 12:28:36 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Ruediger Meier f2bd688157 uuidparse: fix getopt crash
$ ./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>
2017-06-26 22:38:43 +02:00
Karel Zak 47ccf06b47 Merge branch 'usage-part2' of https://github.com/rudimeier/util-linux
* '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
2017-06-26 15:58:37 +02:00
Sami Kerola 83893f2678 uuidparse: add new command
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>
2017-06-26 14:46:35 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
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>
2017-06-26 14:38:24 +02:00
Ruediger Meier fa2cd89aca misc: cosmetics, remove argument from usage(int)
This patch is trivial and changes nothing, because
we were always using usage(0).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6e1eda6f22 misc: never use usage(stderr)
Here we fix all cases where we have usage(FILE*)
functions.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-26 14:38:24 +02:00
Ruediger Meier 5118d1be2a misc: never use usage(ERROR)
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>
2017-06-26 14:38:24 +02:00
Ruediger Meier 6d7bee26bc flock, getopt: write --help to stdout and return 0
... 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>
2017-06-26 14:38:24 +02:00
Karel Zak c3a4cfc579 misc: consolidate usage() "Available columns"
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-06-26 14:09:53 +02:00
Karel Zak d6ec64e824 Merge branch '170622' of github.com:jwpi/util-linux
* '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
2017-06-26 13:56:45 +02:00
Karel Zak dfdb1ca818 Merge branch 'fix-exit-codes' of https://github.com/rudimeier/util-linux
* 'fix-exit-codes' of https://github.com/rudimeier/util-linux:
  misc: fix optutils.h related exit codes
  misc: fix xalloc.h related exit codes
  misc: fix more strutils related exit codes
  lib: fix strutils.h, remove STRTOXX_EXIT_CODE
  misc: fix some broken exit codes
2017-06-26 13:47:04 +02:00
Ruediger Meier a2248466e4 misc: no more errtryh()
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>
2017-06-25 02:22:53 +02:00
J William Piggott 6e2d5a4460 include/c.h: add USAGE_COMMANDS and USAGE_COLUMNS
* login-utils/lslogins.c: all uses changed
* misc-utils/findmnt.c: likewise
* sys-utils/blkzone.c: likewise
* disk-utils/sfdisk.c: likewise
* sys-utils/lscpu.c: likewise
* sys-utils/lsmem.c: likewise
* sys-utils/wdctl.c: likewise

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-06-24 13:57:12 -04:00
Ruediger Meier 778ca2a0d4 misc: fix xalloc.h related exit codes
Found by:

grep -L "XALLOC_EXIT_CODE" $(grep -l "xalloc\.h" \
    $(git grep -l "_EX_\|FINDFS_\|BLKID_EXIT\|EX_USAGE" -- "*.c"))

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 22:40:27 +02:00
Ruediger Meier 9c8b9fbacc lib: fix strutils.h, remove STRTOXX_EXIT_CODE
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>
2017-06-22 22:40:12 +02:00
Ruediger Meier 05691d9e88 misc: fix some broken exit codes
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>
2017-06-22 21:51:40 +02:00
Ruediger Meier 5aaa966dcd whereis: add --help and --version
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>
2017-06-22 21:34:58 +02:00
Ruediger Meier 3b7693cada blkid: use errtryhelp instead of errtryh
We have a --help option and this is preferred.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 21:34:40 +02:00
Ruediger Meier 619081cdab uuidd: remove unused define
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 02:56:57 +02:00
Karel Zak 6f1507f135 wipefs: exit on failed erase
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>
2017-06-21 10:53:28 +02:00
Sami Kerola f4d3783867 misc: remove stray semicolons
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:21:29 +02:00
Sami Kerola 1b5042636f misc: fix reassigned values before old ones has been used [cppcheck]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:19:20 +02:00
Sami Kerola 504c03ecf8 uuidgen: slice up the usage text
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-06-14 12:17:53 +02:00
Sami Kerola 9f430c8a5b rename: notice when expression and replacement are the same string
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>
2017-06-14 12:17:27 +02:00
Sami Kerola b1557fe981 misc: fix ggc-7 fallthrough warnings
(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>
2017-06-14 11:48:22 +02:00
Karel Zak 1d9e35cc1e lsblk: add option --tree
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>
2017-06-09 11:33:18 +02:00