]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agolscpu: (cpuinfo) rewrite parser
Karel Zak [Mon, 20 Jul 2020 20:05:43 +0000 (22:05 +0200)] 
lscpu: (cpuinfo) rewrite parser

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cpuinfo) fill empty cputype
Karel Zak [Mon, 20 Jul 2020 13:43:33 +0000 (15:43 +0200)] 
lscpu: (cpuinfo) fill empty cputype

Don't introduce a new CPU-type if the current is empty.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: new cpuinfo parser
Karel Zak [Fri, 17 Jul 2020 14:21:04 +0000 (16:21 +0200)] 
lscpu: new cpuinfo parser

* extendable by new patterns
* simple semantic
* the same code for all pattern types

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: keep hypervisor name in allocated memory
Karel Zak [Fri, 17 Jul 2020 14:15:02 +0000 (16:15 +0200)] 
lscpu: keep hypervisor name in allocated memory

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: temporary commit
Karel Zak [Fri, 17 Jul 2020 08:39:05 +0000 (10:39 +0200)] 
lscpu: temporary commit

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: improve topology calculation, use /proc/sysinfo
Karel Zak [Thu, 16 Jul 2020 12:58:37 +0000 (14:58 +0200)] 
lscpu: improve topology calculation, use /proc/sysinfo

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: support s390 cpuinfo processor-pre-line format
Karel Zak [Thu, 16 Jul 2020 11:27:13 +0000 (13:27 +0200)] 
lscpu: support s390 cpuinfo processor-pre-line format

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: add lscpu_read_topology_polarization()
Karel Zak [Thu, 16 Jul 2020 10:41:35 +0000 (12:41 +0200)] 
lsblk: add lscpu_read_topology_polarization()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: move topology stuff to separate file
Karel Zak [Thu, 16 Jul 2020 09:32:18 +0000 (11:32 +0200)] 
lscpu: move topology stuff to separate file

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: improve topology debug message
Karel Zak [Thu, 16 Jul 2020 09:13:09 +0000 (11:13 +0200)] 
lscpu: improve topology debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: calculate threads number from type specific values
Karel Zak [Thu, 16 Jul 2020 08:51:14 +0000 (10:51 +0200)] 
lscpu: calculate threads number from type specific values

Don't use global CPU masks (like "online" or "present") to
calculate type specific number of threads due systems with
mixed CPU types.

It's also necessary to check all thread_siblings maps to get the
highest number, because some threads (CPUs) may be disables, for
example old lscpu calculates number of threads from the cpu0 and
if you disable cpu0's sibling (cpu4):

CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2        <---
Core(s) per socket:              4
Socket(s):                       1

 # chcpu --disable 4
 CPU 4 disabled

CPU(s):                          8
On-line CPU(s) list:             0-3,5-7
Off-line CPU(s) list:            4
Thread(s) per core:              1        <--- !
Core(s) per socket:              4
Socket(s):                       1

because 'thread_siblings' contains only one thread for cpu0:

 # cat /sys/devices/system/cpu/cpu{0,1,2,3,4,5,6,7}/topology/thread_siblings_list
 0
 1,5
 2,6
 3,7
 cat: /sys/devices/system/cpu/cpu4/topology/thread_siblings_list: No such file or directory
 1,5
 2,6
 3,7

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: deallocate maps
Karel Zak [Wed, 15 Jul 2020 16:05:15 +0000 (18:05 +0200)] 
lscpu: deallocate maps

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_topolgy_ids()
Karel Zak [Wed, 15 Jul 2020 14:25:15 +0000 (16:25 +0200)] 
lscpu: add lscpu_read_topolgy_ids()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_topology()
Karel Zak [Wed, 15 Jul 2020 14:21:26 +0000 (16:21 +0200)] 
lscpu: add lscpu_read_topology()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_cpus_loopup_by_type(), improve readability
Karel Zak [Wed, 15 Jul 2020 11:07:15 +0000 (13:07 +0200)] 
lscpu: add lscpu_cpus_loopup_by_type(), improve readability

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: convert ARM decoding to new API
Karel Zak [Thu, 14 May 2020 13:20:52 +0000 (15:20 +0200)] 
lscpu: convert ARM decoding to new API

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: cleaup arch freeing
Karel Zak [Thu, 14 May 2020 10:02:44 +0000 (12:02 +0200)] 
lscpu: cleaup arch freeing

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_virtualization()
Karel Zak [Thu, 14 May 2020 09:52:49 +0000 (11:52 +0200)] 
lscpu: add lscpu_read_virtualization()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_numas()
Karel Zak [Wed, 13 May 2020 11:33:36 +0000 (13:33 +0200)] 
lscpu: add lscpu_read_numas()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: fix mem-leak in cpu
Karel Zak [Wed, 13 May 2020 11:33:13 +0000 (13:33 +0200)] 
lscpu: fix mem-leak in cpu

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_vulnerabilities()
Karel Zak [Thu, 7 May 2020 13:23:03 +0000 (15:23 +0200)] 
lscpu: add lscpu_read_vulnerabilities()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: cleanup lscpu_unref_cputype()
Karel Zak [Thu, 7 May 2020 13:08:13 +0000 (15:08 +0200)] 
lscpu: cleanup lscpu_unref_cputype()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_extra()
Karel Zak [Thu, 7 May 2020 13:03:40 +0000 (15:03 +0200)] 
lscpu: add lscpu_read_extra()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_cpulists()
Karel Zak [Thu, 7 May 2020 12:47:24 +0000 (14:47 +0200)] 
lscpu: add lscpu_read_cpulists()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_read_architecture()
Karel Zak [Thu, 7 May 2020 12:19:39 +0000 (14:19 +0200)] 
lscpu: add lscpu_read_architecture()

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cputype) simplify cpuinfo parsing
Karel Zak [Thu, 9 Apr 2020 10:10:43 +0000 (12:10 +0200)] 
lscpu: (cputype) simplify cpuinfo parsing

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add lscpu_cpu to internal API
Karel Zak [Thu, 9 Apr 2020 08:32:11 +0000 (10:32 +0200)] 
lscpu: add lscpu_cpu to internal API

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cputype) move temporary stuff
Karel Zak [Wed, 18 Mar 2020 14:58:53 +0000 (15:58 +0100)] 
lscpu: (cputype) move temporary stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cputype) add header file, cleanup patterns code
Karel Zak [Wed, 18 Mar 2020 14:56:20 +0000 (15:56 +0100)] 
lscpu: (cputype) add header file, cleanup patterns code

* move structs definitions to header file
* define set of /proc/cpuinfo parsing patterns for cpu-type and for
  CPUs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cputype) add cpuinfo parser
Karel Zak [Tue, 17 Mar 2020 16:27:51 +0000 (17:27 +0100)] 
lscpu: (cputype) add cpuinfo parser

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoinclude/strutils: make xstrncpy() compatible with over-smart gcc 9
Karel Zak [Tue, 17 Mar 2020 16:24:28 +0000 (17:24 +0100)] 
include/strutils: make xstrncpy() compatible with over-smart gcc 9

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cputype) add ref-counting, allocate context
Karel Zak [Tue, 17 Mar 2020 12:41:28 +0000 (13:41 +0100)] 
lscpu: (cputype) add ref-counting, allocate context

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: (cputype) add debug stuff
Karel Zak [Tue, 17 Mar 2020 12:30:05 +0000 (13:30 +0100)] 
lscpu: (cputype) add debug stuff

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: add very basic cputype code
Karel Zak [Tue, 17 Mar 2020 12:12:12 +0000 (13:12 +0100)] 
lscpu: add very basic cputype code

The current lscpu assumes that all CPUs in the system are the same.
Unfortunately this is not true. We need to split all internal CPUs
descriptions to CPU-type and CPU.

This patch add lscpu-cputype.c where will be CPU-type description --
mostly based on /proc/cpuinfo.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: update JSON outputs
Karel Zak [Thu, 12 Nov 2020 10:40:22 +0000 (11:40 +0100)] 
tests: update JSON outputs

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/jsonwrt: use proper output function
Karel Zak [Thu, 12 Nov 2020 10:38:55 +0000 (11:38 +0100)] 
lib/jsonwrt: use proper output function

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: use lib/jsonwrt.c for JSON
Karel Zak [Thu, 12 Nov 2020 10:21:50 +0000 (11:21 +0100)] 
libsmartcols: use lib/jsonwrt.c for JSON

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/jsonwrt: add new functions to write in JSON
Karel Zak [Thu, 12 Nov 2020 10:19:13 +0000 (11:19 +0100)] 
lib/jsonwrt: add new functions to write in JSON

We need JSON formatting stuff also outside libsmartcols.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'libblkid' of https://github.com/ferivoz/util-linux
Karel Zak [Tue, 10 Nov 2020 12:37:30 +0000 (13:37 +0100)] 
Merge branch 'libblkid' of https://github.com/ferivoz/util-linux

4 years agotests: (ul) remove another 'dim' input
Karel Zak [Tue, 10 Nov 2020 12:36:32 +0000 (13:36 +0100)] 
tests: (ul) remove another 'dim' input

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: limit amount of parsed partitions
Samanta Navarro [Tue, 10 Nov 2020 10:48:04 +0000 (11:48 +0100)] 
libblkid: limit amount of parsed partitions

The linux kernel does not support more than 256 partitions
(DISK_MAX_PARTS). The atari and mac block devices have no such limits.

Use dos logical partition limit for atari as well (100).
Use the kernel limit for mac (256).

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agolibblkid: fix time_t handling
Samanta Navarro [Sun, 8 Nov 2020 11:46:56 +0000 (11:46 +0000)] 
libblkid: fix time_t handling

The time_t data type is a signed integer. A signed integer overflow is
not defined in C programming language.

A signed overflow occurs on 32 bit systems with 32 time_t for loop back
devices, e.g. when calling "blkid /dev/loop0". This happens because
bid_time is set to INT_MIN and the diff calculation cannot store the
result in time_t (positive int - INT_MIN > INT_MAX).

This fix changes the code to use an unsigned integer calculation. It
pretty much means that the code works as before, but well defined in C.
Checking diff to be positive protects the code against system setups
with dates before 1970 as well.

The time_t data type on modern Linux systems is 64 bit even for 32 bit
systems. Since long is 32 bit on these systems, long long is a better
data type for 64 bit output.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agotests: remove ul(1) 'dim' input
Karel Zak [Mon, 9 Nov 2020 15:41:46 +0000 (16:41 +0100)] 
tests: remove ul(1) 'dim' input

It's not supported by all terminals.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: move misc/ul to ul/ directory
Sami Kerola [Sun, 25 Oct 2020 07:54:37 +0000 (07:54 +0000)] 
tests: move misc/ul to ul/ directory

Reference: https://github.com/karelzak/util-linux/pull/1165#issuecomment-715173662
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agobuild-sys: fix sendfile use
Karel Zak [Mon, 9 Nov 2020 14:30:06 +0000 (15:30 +0100)] 
build-sys: fix sendfile use

* OSX uses different prototype
* include file is not covered by HAVE_SYS_SENDIFLE_H

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agowipefs: (man) add hint to erase on partitions and disk
Karel Zak [Mon, 9 Nov 2020 11:54:18 +0000 (12:54 +0100)] 
wipefs: (man) add hint to erase on partitions and disk

Addresses: https://github.com/karelzak/util-linux/issues/1177
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'libuuid' of https://github.com/ferivoz/util-linux
Karel Zak [Mon, 9 Nov 2020 11:31:17 +0000 (12:31 +0100)] 
Merge branch 'libuuid' of https://github.com/ferivoz/util-linux

* 'libuuid' of https://github.com/ferivoz/util-linux:
  libuuid: check quality of random bytes

4 years agoMerge branch 'vipw-shortwrite' of https://github.com/DankRank/util-linux
Karel Zak [Mon, 9 Nov 2020 10:06:27 +0000 (11:06 +0100)] 
Merge branch 'vipw-shortwrite' of https://github.com/DankRank/util-linux

* 'vipw-shortwrite' of https://github.com/DankRank/util-linux:
  ul_copy_file: make defines for return values
  read_all: return 0 when EOF occurs after 0 bytes
  ul_copy_file: add test program
  ul_copy_file: handle EAGAIN and EINTR
  ul_copy_file: use all_read/all_write
  ul_copy_file: use BUFSSIZ for buffer size
  nologin: use ul_copy_file
  login: use ul_copy_file
  configure.ac: check for sendfile
  ul_copy_file: use sendfile
  vipw: move copyfile to the lib
  vipw: fix short write handling in copyfile

4 years agoflock: keep -E exit status more restrictive
Karel Zak [Mon, 9 Nov 2020 09:53:23 +0000 (10:53 +0100)] 
flock: keep -E exit status more restrictive

Addresses: https://github.com/karelzak/util-linux/issues/1180
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoul_copy_file: make defines for return values
Egor Chelak [Sat, 7 Nov 2020 00:19:56 +0000 (02:19 +0200)] 
ul_copy_file: make defines for return values

Suggested-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoread_all: return 0 when EOF occurs after 0 bytes
Egor Chelak [Fri, 6 Nov 2020 19:09:14 +0000 (21:09 +0200)] 
read_all: return 0 when EOF occurs after 0 bytes

Originally it would return -1 (without setting errno) if the fd was
already at EOF when you called read_all.

This is already fixed in sendfile_all.

Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoul_copy_file: add test program
Egor Chelak [Fri, 6 Nov 2020 19:08:12 +0000 (21:08 +0200)] 
ul_copy_file: add test program

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoul_copy_file: handle EAGAIN and EINTR
Egor Chelak [Fri, 6 Nov 2020 18:33:46 +0000 (20:33 +0200)] 
ul_copy_file: handle EAGAIN and EINTR

I did this by implementing a function called sendfile_all() similar to
read_all()/write_all().

The manpage for sendfile doesn't mention EINTR, but I decided to check
it anyway, just in case.

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoul_copy_file: use all_read/all_write
Egor Chelak [Fri, 6 Nov 2020 17:39:02 +0000 (19:39 +0200)] 
ul_copy_file: use all_read/all_write

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoul_copy_file: use BUFSSIZ for buffer size
Egor Chelak [Fri, 6 Nov 2020 16:35:26 +0000 (18:35 +0200)] 
ul_copy_file: use BUFSSIZ for buffer size

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agonologin: use ul_copy_file
Egor Chelak [Fri, 6 Nov 2020 10:43:18 +0000 (12:43 +0200)] 
nologin: use ul_copy_file

Suggested-by: Sami Kerola <kerolasa@iki.fi>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agologin: use ul_copy_file
Egor Chelak [Fri, 6 Nov 2020 10:37:24 +0000 (12:37 +0200)] 
login: use ul_copy_file

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoconfigure.ac: check for sendfile
Egor Chelak [Fri, 6 Nov 2020 10:15:36 +0000 (12:15 +0200)] 
configure.ac: check for sendfile

Do note that according to man sendfile, "Other UNIX systems implement
sendfile() with different semantics and prototypes."
If this is something we care about, a better check is needed.

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoul_copy_file: use sendfile
Egor Chelak [Fri, 6 Nov 2020 09:15:11 +0000 (11:15 +0200)] 
ul_copy_file: use sendfile

Suggested-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agovipw: move copyfile to the lib
Egor Chelak [Fri, 6 Nov 2020 07:45:18 +0000 (09:45 +0200)] 
vipw: move copyfile to the lib

Also, a bug in pw_tmpfile was fixed: copyfile used tmp_file to report
errors, but pw_tmpfile only assigned that variable _after_ calling
copyfile.

Suggested-by: Sami Kerola <kerolasa@iki.fi>
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agolibuuid: check quality of random bytes
Samanta Navarro [Sun, 8 Nov 2020 11:47:18 +0000 (11:47 +0000)] 
libuuid: check quality of random bytes

If a libuuid application is unable to access /dev/random or /dev/urandom
then uuid generation by uuid_generate falls back to uuid_generate_time.
This could happen in chroot or container environments.

The function ul_random_get_bytes from lib/randutils.c uses getrandom if
it is available. This could either mean that the libuuid application
skips good random bytes because the character special files do not exist
or the application trusts in good random bytes just because these files
are accessible but not necessarily usable, e.g. limit of open file
descriptors reached, lack of data, kernel without getrandom, etc.

This commit modifies ul_random_get_bytes to return an integer which
indicates if random bytes are of good quality (0) or not (1). Callers
can decide based on this information if they want to discard the random
bytes. Only libuuid checks the return value. I decided to return 1
instead of -1 because -1 feels more like an error, but weak random bytes
can be totally fine.

Another issue is that getrandom sets errno to specific values only in
case of an error, i.e. with return value -1. Set errno to 0 explicitly
if getrandom succeeds so we do not enter the fallback routine for
ENOSYS by mistake. I do not think that this is likely to happen, but it
really depends on possible wrapper function supplied by a C library.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agolibblkid: allow a lot of mac partitions
Samanta Navarro [Sun, 8 Nov 2020 11:45:18 +0000 (11:45 +0000)] 
libblkid: allow a lot of mac partitions

If the map count is set to INT_MAX then the for loop does not stop
because its check is never false.

I have not found a correct upper limit. The other partition logics have
a maximum amount (exception is atari.c).

The loop itself wouldn't be endless. If the iteration reaches block 0
then the signature will be wrong. This means that map count = INT_MAX
case would fail even if such a setup would be correct on disk.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agolibblkid: fix memory leak in config parser
Samanta Navarro [Sun, 8 Nov 2020 11:44:55 +0000 (11:44 +0000)] 
libblkid: fix memory leak in config parser

Multiple occurrences of CACHE_FILE lead to memory leaks.
Also if last occurrence of CACHE_FILE is empty then cache file is not
set to NULL again.

An example /etc/blkid.conf could be:

CACHE_FILE=/tmp/cache1
CACHE_FILE=/tmp/cache2
CACHE_FILE=

I would expect that CACHE_FILE is empty but actually it is still
/tmp/cache2.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agosfdisk: fix backward --move-data
Karel Zak [Fri, 6 Nov 2020 10:38:51 +0000 (11:38 +0100)] 
sfdisk: fix backward --move-data

* fix final message where number of moved sectors overflow number of
  all moved sectors

* align last step size before we use it for backward mode source and
  destination offsets calculation

Addresses: https://github.com/karelzak/util-linux/issues/1176
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'whereis' of https://github.com/ferivoz/util-linux
Karel Zak [Fri, 6 Nov 2020 08:44:52 +0000 (09:44 +0100)] 
Merge branch 'whereis' of https://github.com/ferivoz/util-linux

* 'whereis' of https://github.com/ferivoz/util-linux:
  whereis: extend test case
  whereis: filter bin, man and src differently
  whereis: do not strip suffixes
  whereis: do not ignore trailing numbers
  whereis: add --disable-whereis to configure
  whereis: add lib32 directories
  whereis: support zst compressed man pages
  whereis: fix out of boundary read

4 years agoMerge branch 'sfdisk-json-dump' of https://github.com/xnox/util-linux
Karel Zak [Thu, 5 Nov 2020 10:37:51 +0000 (11:37 +0100)] 
Merge branch 'sfdisk-json-dump' of https://github.com/xnox/util-linux

4 years agosfdisk: correct --json --dump false exclusive
Dimitri John Ledkov [Wed, 4 Nov 2020 12:35:38 +0000 (12:35 +0000)] 
sfdisk: correct --json --dump false exclusive

`--json` implies `--dump`, thus `--json --dump` must be
allowed. `--list-free` is incompatible with `--dump`, and thus also
with `--json`. Currently `--json --dump` is prohibited, even though
`--list-free` is not specified at all.

Regression introduced in 03154d2cf25c1d5ce908da9e72d324004b8d5722.

Signed-off-by: Dimitri John Ledkov <xnox@ubuntu.com>
4 years agowhereis: extend test case
Samanta Navarro [Wed, 4 Nov 2020 11:39:00 +0000 (11:39 +0000)] 
whereis: extend test case

Previous commits are covered with these test cases.

Removed dependency on system layout.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: filter bin, man and src differently
Samanta Navarro [Wed, 4 Nov 2020 11:38:00 +0000 (11:38 +0000)] 
whereis: filter bin, man and src differently

Consider "s." prefixes for source code files only (even though I do not
know which VCS does that), compression suffixes for manual pages and
strict matching for executables.

Calling "whereis python3" is kind of okay to return python3.8 next to
python3, but python3.8-config is not the same tool as python3.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: do not strip suffixes
Samanta Navarro [Wed, 4 Nov 2020 11:37:00 +0000 (11:37 +0000)] 
whereis: do not strip suffixes

The whereis implementations of FreeBSD, macOS, NetBSD, and OpenBSD do
not strip suffixes. Although whereis is not a POSIX tool and has no
shared standard, even its manual page indicates that the supplied names
are command names.

Commands do not have a suffix on Linux systems.

Stripping suffixes actually leads to issues with tools like fsck.ext4,
since fsck.ext4 is not the same tool as fsck and definitely not the same
tool as fsck.minix.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: do not ignore trailing numbers
Samanta Navarro [Wed, 4 Nov 2020 11:36:00 +0000 (11:36 +0000)] 
whereis: do not ignore trailing numbers

The commands diff and diff3 are so distinct that their manual pages
should not be mixed in whereis output.

Theoretically this works for commands and binaries with links to each
other, e.g. gpg and gpg2, but if gpg is version 1 and gpg2 is version 2
then manual pages do not match either.

Also the while loop does not decrement "i" while incrementing "dp". The
effect of this is that the output of whereis depends on manual pages
being compressed or not.

The easiest solution is to not ignore trailing numbers.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: add --disable-whereis to configure
Samanta Navarro [Wed, 4 Nov 2020 11:35:00 +0000 (11:35 +0000)] 
whereis: add --disable-whereis to configure

Allow a build of util-linux without whereis.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: add lib32 directories
Samanta Navarro [Wed, 4 Nov 2020 11:34:00 +0000 (11:34 +0000)] 
whereis: add lib32 directories

These directories are sometimes used by Linux distributions.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: support zst compressed man pages
Samanta Navarro [Wed, 4 Nov 2020 11:33:00 +0000 (11:33 +0000)] 
whereis: support zst compressed man pages

Add zst as extension for manual pages. Current version of man-db
supports zst extension out of the box.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agowhereis: fix out of boundary read
Samanta Navarro [Wed, 4 Nov 2020 11:32:00 +0000 (11:32 +0000)] 
whereis: fix out of boundary read

If whereis encounters a short file name then an out of boundary
read can occur.

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agomisc: fix typos
Samanta Navarro [Wed, 4 Nov 2020 11:31:00 +0000 (11:31 +0000)] 
misc: fix typos

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agomisc: fix typos [codespell]
Samanta Navarro [Wed, 4 Nov 2020 11:30:00 +0000 (11:30 +0000)] 
misc: fix typos [codespell]

Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
4 years agosfdisk: (docs) add more information about GPT attribute bits
Karel Zak [Wed, 4 Nov 2020 09:29:30 +0000 (10:29 +0100)] 
sfdisk: (docs) add more information about GPT attribute bits

Addresses: https://github.com/karelzak/util-linux/issues/1171
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodocs: rename to getopt-example
Karel Zak [Tue, 3 Nov 2020 14:23:03 +0000 (15:23 +0100)] 
docs: rename to getopt-example

Addresses: https://github.com/karelzak/util-linux/commit/27114b297424ecf1b745b1a71f6d40be0e56e67e#commitcomment-43591002
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'execl-null' of https://github.com/DankRank/util-linux
Karel Zak [Tue, 3 Nov 2020 11:40:35 +0000 (12:40 +0100)] 
Merge branch 'execl-null' of https://github.com/DankRank/util-linux

* 'execl-null' of https://github.com/DankRank/util-linux:
  cast NULL to char * when using execl

4 years agolib/randutils: rename random_get_bytes()
Sami Kerola [Mon, 2 Nov 2020 22:26:18 +0000 (22:26 +0000)] 
lib/randutils: rename random_get_bytes()

Rename random_get_bytes() to avoid colliding a Solaris library function that
has the same name.

Reported-by: Sad Clouds <cryintothebluesky@gmail.com>
Reference: https://lore.kernel.org/util-linux/20201101141608.ba365cf67d92ee3973226de9@gmail.com/
Reference: https://blogs.oracle.com/solaris/solaris-random-number-generation-v2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocast NULL to char * when using execl
Egor Chelak [Thu, 29 Oct 2020 17:49:07 +0000 (19:49 +0200)] 
cast NULL to char * when using execl

When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.

The call in newgrp.c was changed for consistency.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agovipw: fix short write handling in copyfile
Egor Chelak [Thu, 29 Oct 2020 17:06:13 +0000 (19:06 +0200)] 
vipw: fix short write handling in copyfile

Since `off` and `nr` approach each other, the for-loop ends prematurely
when at least half of the buffer was written.  I think under certain
conditions this could cause the copy to be incomplete.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
4 years agoul: fix use of unsigned number
Karel Zak [Wed, 21 Oct 2020 10:45:02 +0000 (12:45 +0200)] 
ul: fix use of unsigned number

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agodmesg: add --since and --until
Karel Zak [Wed, 21 Oct 2020 10:03:45 +0000 (12:03 +0200)] 
dmesg: add --since and --until

$ date
Wed 21 Oct 2020 12:05:07 PM CEST

$ dmesg --ctime --since '1 hour ago'
[Wed Oct 21 11:47:13 2020] AAA
[Wed Oct 21 11:55:48 2020] BBB

$ dmesg --ctime --since '1 hour ago' --until '10 minutes ago'
[Wed Oct 21 11:47:13 2020] AAA

Addresses: https://github.com/karelzak/util-linux/issues/1166
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoul: small coding changes
Karel Zak [Wed, 21 Oct 2020 09:16:34 +0000 (11:16 +0200)] 
ul: small coding changes

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'ul-refactor' of https://github.com/kerolasa/util-linux
Karel Zak [Wed, 21 Oct 2020 09:08:11 +0000 (11:08 +0200)] 
Merge branch 'ul-refactor' of https://github.com/kerolasa/util-linux

* 'ul-refactor' of https://github.com/kerolasa/util-linux:
  ul: flip comparisons to lesser to greater order
  ul: use size_t to measure memory allocation size
  ul: improve function and variable names
  ul: rename enumerated mode symbols
  ul: remove function like putwp preprocessor define
  ul: free most allocations ncurses did during setupterm()
  ul: replace global runtime variables with a control structure
  ul: add a term capabilities tracking structure
  ul: remove function prototypes
  ul: tidy up coding style
  ul: add basic tests

4 years agocal: do not use putp(), directly use stdio functions
Karel Zak [Wed, 21 Oct 2020 08:19:26 +0000 (10:19 +0200)] 
cal: do not use putp(), directly use stdio functions

It seems our putp() based output is not portable as some ncurses
implementations strictly follow POSIX where putp() accepts only
terminfo capability strings and nothing else.

We already use standard stdio.h functions to output terminfo strings
(e.g.  for colors). It seems we can do the same for cal(1) to
highlight the current day.

Note that mix putp() and fputs() is bad idea due to different
buffering ways in some cases (see cal.c git log for more details).

This patch also reduces complexity of the code as we can directly
output to stdout without snprintf to string.

Addresses: https://github.com/karelzak/util-linux/pull/1167
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoul: flip comparisons to lesser to greater order
Sami Kerola [Fri, 16 Oct 2020 21:35:06 +0000 (22:35 +0100)] 
ul: flip comparisons to lesser to greater order

1 < 2 < x < 4 is the order is the natural of values.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: use size_t to measure memory allocation size
Sami Kerola [Fri, 16 Oct 2020 21:26:15 +0000 (22:26 +0100)] 
ul: use size_t to measure memory allocation size

The size_t is the type libc memory allocation functions use.  The size_t
also provides allocation range that is enough not to a simple tool like this
to perform paranoia size checks.  Just let the realloc(3) fail if there is
not enough memory available to handle the requested line size.  That is a
lot more straightforward.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: improve function and variable names
Sami Kerola [Fri, 16 Oct 2020 20:42:18 +0000 (21:42 +0100)] 
ul: improve function and variable names

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: rename enumerated mode symbols
Sami Kerola [Wed, 14 Oct 2020 21:51:37 +0000 (22:51 +0100)] 
ul: rename enumerated mode symbols

First two are are ISO/IEC 2022 graphic character sets G0 (normal) and G1
(alternative), that one has to Switch In (SI) and Switch Out (SO).  The rest
are about how ul(1) is interacting with various text emphasis.

Reference: https://tldp.org/HOWTO/Keyboard-and-Console-HOWTO-6.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: remove function like putwp preprocessor define
Sami Kerola [Wed, 14 Oct 2020 21:15:03 +0000 (22:15 +0100)] 
ul: remove function like putwp preprocessor define

The #ifdef HAVE_WIDECHAR can be removed, because the command already is
using wide character functions elsewhere without fallbacks.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: free most allocations ncurses did during setupterm()
Sami Kerola [Sat, 1 Aug 2020 23:58:35 +0000 (00:58 +0100)] 
ul: free most allocations ncurses did during setupterm()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: replace global runtime variables with a control structure
Sami Kerola [Tue, 30 Jun 2020 21:17:01 +0000 (22:17 +0100)] 
ul: replace global runtime variables with a control structure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: add a term capabilities tracking structure
Sami Kerola [Mon, 29 Jun 2020 21:00:14 +0000 (22:00 +0100)] 
ul: add a term capabilities tracking structure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: remove function prototypes
Sami Kerola [Mon, 29 Jun 2020 20:41:38 +0000 (21:41 +0100)] 
ul: remove function prototypes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: tidy up coding style
Sami Kerola [Mon, 29 Jun 2020 20:21:50 +0000 (21:21 +0100)] 
ul: tidy up coding style

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoul: add basic tests
Sami Kerola [Sat, 1 Aug 2020 12:20:30 +0000 (13:20 +0100)] 
ul: add basic tests

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolibmount: Fix 0x%u usage
Dr. David Alan Gilbert [Sat, 17 Oct 2020 12:05:34 +0000 (13:05 +0100)] 
libmount: Fix 0x%u usage

There's a couple of places which use varients on "0x%u" in format strings;
that's almost always wrong - you either want 0x%x or just %u.  In libmount's
case it's flags, so I'm assuming the intention really is hex.  In the ja.po
case it's %u in the original msgid.

Signed-off-by: Dr. David Alan Gilbert <dave@treblig.org>