]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
4 years agobuild-sys: add missing header file
Karel Zak [Wed, 30 Sep 2020 12:03:15 +0000 (14:03 +0200)] 
build-sys: add missing header file

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocol: enable deallocation on exit also for __SANITIZE_ADDRESS__
Karel Zak [Wed, 30 Sep 2020 11:47:35 +0000 (13:47 +0200)] 
col: enable deallocation on exit also for __SANITIZE_ADDRESS__

The macro FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION does not have to
enabled in all cases (e.g. default travis-ci, local tests, ...). It
seems more robust also check for __SANITIZE_ADDRESS__ too.

Addresses: https://github.com/karelzak/util-linux/pull/1115
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: (gpt) accept tiny devices
Karel Zak [Wed, 30 Sep 2020 11:11:01 +0000 (13:11 +0200)] 
libblkid: (gpt) accept tiny devices

GPT prober reads 2 first sectors. There is no overhead as we already
read begin of the device for another filesystems (like FAT) and we
have these sectors already in memory.

Addresses: https://github.com/karelzak/util-linux/issues/1147
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (gpt) reduce number of entries to fit small device
Karel Zak [Wed, 30 Sep 2020 10:38:59 +0000 (12:38 +0200)] 
libfdisk: (gpt) reduce number of entries to fit small device

The default is 128 partitions (entries in partitions array). The size
of the entry is 128 bytes, it means 32 sectors (512-byte) for the
array. The default is too large for tiny devices and it seems better to
dynamically reduce the number to fix the device size.

The reduction is reported to user.

Example:

 $ dd if=/dev/zero of=8-sectors.img count=8 bs=512
 $ fdisk 8-sectors.img
 ...
 Command (m for help): g
 Created a new GPT disklabel (GUID: 3DB3EECE-BCCA-6C46-95FA-7E23783BB3B2).
 The maximal number of partitions is 8 (default is 128).

 Command (m for help): x

 Expert command (m for help): p
 Disk 8-sectors.img: 4 KiB, 4096 bytes, 8 sectors
 Units: sectors of 1 * 512 = 512 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disklabel type: gpt
 Disk identifier: 3DB3EECE-BCCA-6C46-95FA-7E23783BB3B2
 First LBA: 4
 Last LBA: 4
 Alternative LBA: 7
 Partition entries LBA: 2
 Allocated partition entries: 8

In this case, sectors:
 0   - PMBR
 1   - GPT header
 2-3 - GPT array of partitions (8 entries, 128 bytes each)
 4   - partition data
 5-6 - backup GPT array of partitions
 7   - backup GPT header

The smallest image is 6 sectors with 4 entries in array of partitions.

Note that Linux kernel has no problem to accept 4K image with 1
512-bytes GPT partition.

  # losetup -P -f 4K.img
  # lsblk /dev/loop0
  NAME      MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
  loop0       7:0    0    4K  0 loop
  └─loop0p1 259:5    0  512B  0 part

... but we need to fix libblkid, it ignores so small devices to probe for GPT :)

Addresses: https://github.com/karelzak/util-linux/issues/1147
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofdisk: always report fdisk_create_disklabel() errors
Karel Zak [Wed, 30 Sep 2020 09:49:05 +0000 (11:49 +0200)] 
fdisk: always report fdisk_create_disklabel() errors

This is fdisk, cfdisk and sfdisk change to inform user about fdisk_create_disklabel()
issues.

Addresses: https://github.com/karelzak/util-linux/issues/1147
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: (gpt) make sure device is large enough
Karel Zak [Wed, 30 Sep 2020 09:44:03 +0000 (11:44 +0200)] 
libfdisk: (gpt) make sure device is large enough

The current code creates GPT header and partitions arrays (with 128
entries ...) although there is no space for all the stuff. This patch
forces fdisk_create_disklabel() to return -ENOSPC if the last and first
usable LBA calculation is out of device size.

Addresses: https://github.com/karelzak/util-linux/issues/1147
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibblkid: improve debug for /proc/partitions
Karel Zak [Wed, 30 Sep 2020 09:37:09 +0000 (11:37 +0200)] 
libblkid: improve debug for /proc/partitions

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocol: cleanup usage() and struct col_*
Karel Zak [Tue, 29 Sep 2020 12:20:57 +0000 (14:20 +0200)] 
col: cleanup usage() and struct col_*

- remove extra line about stdout in usage() output

- use our macros to print int about --help and --version

- remove uint8_t bit-field from struct col_ctl (it seems fragile for
  future code changes).

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'col-refactor' of https://github.com/kerolasa/util-linux
Karel Zak [Tue, 29 Sep 2020 11:41:00 +0000 (13:41 +0200)] 
Merge branch 'col-refactor' of https://github.com/kerolasa/util-linux

* 'col-refactor' of https://github.com/kerolasa/util-linux:
  col: replace LINE and CHAR typedefs with structs
  col: free memory before exit [LeakSanitizer]
  col: tidy up sources a little bit
  col: add defaults to switch case clauses
  col: flip all comparisions to numerical order
  col: use size_t when dealing with numbers that buffer sizes
  col: add structure to hold line variables
  col: add update_cur_line() function
  col: add handle_not_graphic() function
  col: initialize variables when they are declared
  col: move option handling to separate function
  col: move global variables to a control structure
  col: use inline function rather than function like define
  col: use typedef and enum to clarify struct
  col: remove function prototypes
  col: add more tests

4 years agolscpu: use SMBIOS tables on ARM for lscpu
Jeffrey Bastian [Tue, 29 Sep 2020 11:28:16 +0000 (13:28 +0200)] 
lscpu: use SMBIOS tables on ARM for lscpu

ARM SBBR (Sever Base Boot Requirements) require SMBIOS tables, and
SMBIOS Type 4 describes the CPU manufacturer and model name (among other
details).  If SMBIOS Type 4 is present, use it to extract these strings.

Example output (before and after the patch) on an HP m400, Lenovo HR330A,
and HPE Apollo 70:

[root@hp-m400 ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           APM
Model:               1
Model name:          X-Gene
Stepping:            0x0
[root@hp-m400 ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       AppliedMicro
Model:                           1
Model name:                      X-Gene
Stepping:                        0x0

[root@lenovo-hr330a ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           APM
Model:               2
Model name:          X-Gene
Stepping:            0x3
[root@lenovo-hr330a ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       Ampere(TM)
Model:                           2
Model name:                      eMAG
Stepping:                        0x3

[root@hpe-apollo-70 ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           Cavium
Model:               1
Model name:          ThunderX2 99xx
Stepping:            0x1
[root@hpe-apollo-70 ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       Cavium Inc.
Model:                           1
Model name:                      Cavium ThunderX2(R) CPU CN9980 v2.1 @ 2.20GHz
Stepping:                        0x1

[kzak@redhat.com: - move dmi_header to lscpu.h
                  - make arm_cpu_smbios() more robust for failed
    open() and read()
                  - use original arm_cpu_decode() also on failed
    arm_cpu_smbios()]

Signed-off-by: Jeffrey Bastian <jbastian@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: Add FUJITSU aarch64 A64FX cpupart
Shunsuke Nakamura [Mon, 28 Sep 2020 09:46:14 +0000 (18:46 +0900)] 
lscpu: Add FUJITSU aarch64 A64FX cpupart

Add an entry for FUJITSU aarch64 part A64FX.
I tested it on the FX1000.

Signed-off-by: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
4 years agocolumn: Deprecate --table-empty-lines in favor of --keep-empty-lines
Lennard Hofmann [Mon, 21 Sep 2020 16:26:00 +0000 (18:26 +0200)] 
column: Deprecate --table-empty-lines in favor of --keep-empty-lines

`--table-empty-lines` gives the false impression that the option
only applies to table mode.

Signed-off-by: Lennard Hofmann <lennard.hofmann@web.de>
4 years agocolumn: Optionally keep empty lines in cols/rows mode
Lennard Hofmann [Mon, 21 Sep 2020 16:16:20 +0000 (18:16 +0200)] 
column: Optionally keep empty lines in cols/rows mode

Signed-off-by: Lennard Hofmann <lennard.hofmann@web.de>
4 years agoMerge branch 'blockdev' of https://github.com/jwilk-forks/util-linux
Karel Zak [Tue, 29 Sep 2020 10:34:45 +0000 (12:34 +0200)] 
Merge branch 'blockdev' of https://github.com/jwilk-forks/util-linux

4 years agoMerge branch 'master' of https://github.com/tabraham/util-linux
Karel Zak [Tue, 29 Sep 2020 10:34:08 +0000 (12:34 +0200)] 
Merge branch 'master' of https://github.com/tabraham/util-linux

4 years agolibmount: optimize mnt_optstr_apply_flags()
Karel Zak [Tue, 29 Sep 2020 10:31:06 +0000 (12:31 +0200)] 
libmount: optimize mnt_optstr_apply_flags()

We append to the options string in loop there. It seems better to use
ul_buffer for this case to avoid duplicate strlen() and reallocs.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: improve mnt_split_optstr() performance
Karel Zak [Fri, 25 Sep 2020 15:23:18 +0000 (17:23 +0200)] 
libmount: improve mnt_split_optstr() performance

This function is used by fstab (etc.) parser to split VFS, FS and
userspace options to separate lists. Unfortunately, the current
implementation reallocates the final string always when append a new
option to the string.

The new implementation pre-allocate memory for the final string
according to source string length (1/2 of the original string). This
dramatically reduces realloc() calls.

For example oss-fuzz (./test_mount_fuzz) uses 800K input string, old
version needs 28s to parse the string, new version 500ms.

Addresses: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=23861
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/buffer: add simple grow-able buffer
Karel Zak [Fri, 25 Sep 2020 15:21:57 +0000 (17:21 +0200)] 
lib/buffer: add simple grow-able buffer

The goal is to use it in libmount when generate options strings
and in libsmartcols to replace libscols_buffer.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoblockdev: fix man page formatting
Jakub Wilk [Sat, 26 Sep 2020 16:15:42 +0000 (18:15 +0200)] 
blockdev: fix man page formatting

Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
4 years agolibmount: (optstr) improve default initialization
Karel Zak [Fri, 25 Sep 2020 08:25:25 +0000 (10:25 +0200)] 
libmount: (optstr) improve default initialization

Don't use memset() if we can use compiler for the first
initialization.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolscpu: avoid segfault on PowerPC systems with valid hardware configurations
Thomas Abraham [Thu, 24 Sep 2020 18:52:33 +0000 (14:52 -0400)] 
lscpu: avoid segfault on PowerPC systems with valid hardware configurations

ntypes greater than 1 is valid in some hardware configurations, and an assert()
on the value isn't necessary or very future proof

4 years agolsblk: fix SCSI_IDENT_SERIAL
Karel Zak [Thu, 24 Sep 2020 07:56:03 +0000 (09:56 +0200)] 
lsblk: fix SCSI_IDENT_SERIAL

It seems sg3_utils does not use ID_ prefix like other udev stuff.

Addresses: https://github.com/karelzak/util-linux/issues/1143
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agosu: remove useless assignment
Karel Zak [Wed, 23 Sep 2020 14:54:34 +0000 (16:54 +0200)] 
su: remove useless assignment

Address: https://github.com/karelzak/util-linux/issues/1145
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: read ID_SCSI_IDENT_SERIAL if available
Karel Zak [Wed, 23 Sep 2020 13:41:05 +0000 (15:41 +0200)] 
lsblk: read ID_SCSI_IDENT_SERIAL if available

This SERIAL comes from sg3_utils.

Addresses: https://github.com/karelzak/util-linux/issues/1143
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibfdisk: add "Linux /usr" and "Linux /usr verity" GPT partition types
nl6720 [Mon, 21 Sep 2020 15:20:16 +0000 (18:20 +0300)] 
libfdisk: add "Linux /usr" and "Linux /usr verity" GPT partition types

See https://systemd.io/DISCOVERABLE_PARTITIONS/ and https://github.com/systemd/systemd/pull/17101 .

Move ARM after x86-64, so that x86 and x86-64 are next to one another.

Signed-off-by: nl6720 <nl6720@gmail.com>
4 years agotests: update script(1) return code
Karel Zak [Mon, 21 Sep 2020 11:34:06 +0000 (13:34 +0200)] 
tests: update script(1) return code

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: kill child process on error
Karel Zak [Mon, 21 Sep 2020 10:51:02 +0000 (12:51 +0200)] 
script: kill child process on error

The recent change in code improves main-pool on error, but we need
to kill child process if it still running to avoid hang up in next
waitpid().

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoscript: improve I/O return code checks
Soumendra Ganguly [Tue, 15 Sep 2020 14:14:59 +0000 (09:14 -0500)] 
script: improve I/O return code checks

Handle error based on return code of handle_io() and handle_signal().
Keep SIGTTIN unblocked during read() in handle_io().

Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
4 years agodocs: add note about github
Karel Zak [Tue, 15 Sep 2020 07:01:13 +0000 (09:01 +0200)] 
docs: add note about github

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agofallocate: fix --dig-holes at end of files
Gero Treuner [Thu, 10 Sep 2020 19:43:03 +0000 (21:43 +0200)] 
fallocate: fix --dig-holes at end of files

I discovered that making a file sparse with "fallocate -d filename"
fails on the last block of a file, because - usually being partial -
the system call only zeroes that part instead of deallocating the
block. See man fallocate(2) - section "Deallocating file space".

The expected call is punching the whole block beyond eof, which
doesn't change the file length because of flag FALLOC_FL_KEEP_SIZE.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'addCarmelLscpu' of https://github.com/tomoaki0705/util-linux
Karel Zak [Mon, 14 Sep 2020 08:49:28 +0000 (10:49 +0200)] 
Merge branch 'addCarmelLscpu' of https://github.com/tomoaki0705/util-linux

* 'addCarmelLscpu' of https://github.com/tomoaki0705/util-linux:
  add Carmel from NVIDIA

4 years agocol: replace LINE and CHAR typedefs with structs
Sami Kerola [Sat, 12 Sep 2020 18:18:36 +0000 (19:18 +0100)] 
col: replace LINE and CHAR typedefs with structs

Karel Zak said; typedef is evil, see reference.  I don't know are they evil,
but it is fair comment structs without hiding what is the data type is
easier and quicker understand when reading the code.

Reference: https://github.com/karelzak/util-linux/pull/1115#discussion_r481971317
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: free memory before exit [LeakSanitizer]
Sami Kerola [Sat, 8 Aug 2020 15:49:09 +0000 (16:49 +0100)] 
col: free memory before exit [LeakSanitizer]

Clean up before exit to satisfy LeakSanitizer tests run by travis.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: tidy up sources a little bit
Sami Kerola [Sun, 28 Jun 2020 16:59:59 +0000 (17:59 +0100)] 
col: tidy up sources a little bit

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: add defaults to switch case clauses
Sami Kerola [Sun, 28 Jun 2020 16:08:47 +0000 (17:08 +0100)] 
col: add defaults to switch case clauses

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: flip all comparisions to numerical order
Sami Kerola [Sun, 28 Jun 2020 12:24:28 +0000 (13:24 +0100)] 
col: flip all comparisions to numerical order

Left side is always smaller or equal to right side.  This makes reading code
quicker when not having to constantly swap where is the greater value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: use size_t when dealing with numbers that buffer sizes
Sami Kerola [Sun, 28 Jun 2020 11:54:24 +0000 (12:54 +0100)] 
col: use size_t when dealing with numbers that buffer sizes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: add structure to hold line variables
Sami Kerola [Sun, 28 Jun 2020 11:40:13 +0000 (12:40 +0100)] 
col: add structure to hold line variables

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: add update_cur_line() function
Sami Kerola [Sun, 28 Jun 2020 11:20:03 +0000 (12:20 +0100)] 
col: add update_cur_line() function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: add handle_not_graphic() function
Sami Kerola [Sat, 27 Jun 2020 19:50:55 +0000 (20:50 +0100)] 
col: add handle_not_graphic() function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: initialize variables when they are declared
Sami Kerola [Sat, 27 Jun 2020 18:44:46 +0000 (19:44 +0100)] 
col: initialize variables when they are declared

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: move option handling to separate function
Sami Kerola [Sat, 27 Jun 2020 18:32:25 +0000 (19:32 +0100)] 
col: move option handling to separate function

Mark --tabs and --spaces mutually exclusive in same go.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: move global variables to a control structure
Sami Kerola [Sat, 27 Jun 2020 18:23:29 +0000 (19:23 +0100)] 
col: move global variables to a control structure

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: use inline function rather than function like define
Sami Kerola [Sat, 27 Jun 2020 18:03:33 +0000 (19:03 +0100)] 
col: use inline function rather than function like define

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: use typedef and enum to clarify struct
Sami Kerola [Sat, 27 Jun 2020 17:57:48 +0000 (18:57 +0100)] 
col: use typedef and enum to clarify struct

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: remove function prototypes
Sami Kerola [Sat, 27 Jun 2020 17:40:44 +0000 (18:40 +0100)] 
col: remove function prototypes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agocol: add more tests
Sami Kerola [Fri, 26 Jun 2020 21:24:25 +0000 (22:24 +0100)] 
col: add more tests

With these tests coverage is about 89%.

The ts_run is added to ensure ASAN_OPTIONS and UBSAN_OPTIONS are set
correctly when the tests run.

Reference: https://github.com/karelzak/util-linux/pull/1115#issuecomment-670140224
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agoadd Carmel from NVIDIA
Tomoaki Teshima [Fri, 11 Sep 2020 13:45:54 +0000 (22:45 +0900)] 
add Carmel from NVIDIA

4 years agoblkzone: add report capacity command
Hans Holmberg [Fri, 11 Sep 2020 08:47:23 +0000 (10:47 +0200)] 
blkzone: add report capacity command

Add a command that answers the the question:
"How much data can I store on this device/in this range of zones?"

Implement this by summing up zone capacities over the given range.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
4 years agologin: add option to not reset username on each attempt
Thayne McCombs [Fri, 4 Sep 2020 08:33:54 +0000 (02:33 -0600)] 
login: add option to not reset username on each attempt

[kzak@redhat.com: - use different message on failed password]

Addresses: https://github.com/karelzak/util-linux/pull/1138
Addresses: https://github.com/karelzak/util-linux/issues/6
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomkswap: add --verbose, reduce extents check output
Karel Zak [Thu, 10 Sep 2020 10:54:14 +0000 (12:54 +0200)] 
mkswap: add --verbose, reduce extents check output

We do not need to provide details in the default output. It seems
better to hide it behind --verbose to be user-friendly.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomkswap: cleanup usage()
Karel Zak [Thu, 10 Sep 2020 09:26:18 +0000 (11:26 +0200)] 
mkswap: cleanup usage()

- don't use one string for all --help output
- use USAGE_* macros

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomkswap: remove unnecessary on FS_IOC_FIEMAP
Karel Zak [Wed, 9 Sep 2020 13:50:39 +0000 (15:50 +0200)] 
mkswap: remove unnecessary on FS_IOC_FIEMAP

This is something user cannot fix and extents check is nothing critical.

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomkswap: improve extents check
Karel Zak [Wed, 9 Sep 2020 13:37:27 +0000 (15:37 +0200)] 
mkswap: improve extents check

- remove unknown extent type (kernel does not care about it too)
- fix last_logical use in messages
- improve warning for DELALLOC extents
- check for hole at the end of the file

Reported-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: show all empty, except loopdevs
Karel Zak [Wed, 9 Sep 2020 12:50:02 +0000 (14:50 +0200)] 
lsblk: show all empty, except loopdevs

This patch improves the previous commit to accept also another empty devices.

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: ignore only loopdevs without backing file
Karel Zak [Wed, 9 Sep 2020 10:18:07 +0000 (12:18 +0200)] 
lsblk: ignore only loopdevs without backing file

* do not ignore all empty devices, we need more smart solution

* ignore only loop devices without backing file, for example:
 # touch img
 # losetup -f img
 losetup: img: Warning: file is smaller than 512 bytes; the loop device may be useless or invisible for system tools.

 - old version display nothing
 - new version:

 # lsblk /dev/loop0
 NAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
 loop0   7:0    0   0B  0 loop

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolsblk: print zero rather than empty SIZE
Karel Zak [Wed, 9 Sep 2020 10:00:10 +0000 (12:00 +0200)] 
lsblk: print zero rather than empty SIZE

Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'cramfs-use-prepared-test-data' of https://github.com/masami256/util...
Karel Zak [Wed, 9 Sep 2020 09:23:48 +0000 (11:23 +0200)] 
Merge branch 'cramfs-use-prepared-test-data' of https://github.com/masami256/util-linux

4 years agoMerge branch 'nosymfollow' of https://github.com/rzwisler/util-linux
Karel Zak [Wed, 9 Sep 2020 09:13:34 +0000 (11:13 +0200)] 
Merge branch 'nosymfollow' of https://github.com/rzwisler/util-linux

* 'nosymfollow' of https://github.com/rzwisler/util-linux:
  mount: Add support for "nosymfollow" mount option.

4 years agomkswap: check for holes and unwanted extentd in file
Karel Zak [Wed, 9 Sep 2020 09:00:40 +0000 (11:00 +0200)] 
mkswap: check for holes and unwanted extentd in file

Let's make mkswap(8) more user-friend and report possible swapon
issues already when user initialize a swap file. The extents check
produces warnings, no exit with error.

  # dd if=/dev/zero of=img count=100 bs=1MiB
  # chmod 0600 img

  # fallocate --dig-hole --offset 64520192 --length 1MiB img
  # fallocate --dig-hole --offset 84520960 --length 1MiB img

  # ./mkswap img
  mkswap: extents check failed:
    - hole detected at offset 64520192 (size 1048576 bytes)
    - hole detected at offset 84520960 (size 1048576 bytes)
  file img can be rejected by kernel on swap activation.

  Setting up swapspace version 1, size = 100 MiB (104853504 bytes)
  no label, UUID=92091112-26b5-47aa-a02a-592e52528319

It checks for holes in the file, and for unknown, inline, shared and
deallocated extents.

Addresses: https://github.com/karelzak/util-linux/issues/1120
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: mkfs-endianness test uses prepared test data
Masami Ichikawa [Tue, 8 Sep 2020 05:19:32 +0000 (14:19 +0900)] 
tests: mkfs-endianness test uses prepared test data

Commit 7b54f05d6b7124c23bff3bc1b8310231c8a2e131 added iflag=fullblock
option, it works fine with coreutils's dd but macOS's dd doesn't support
iflag option then test failed on macOS[1].

This commit added prepared test data for test to not use dd command to
avoid dd command difference.

tested on raspberry pi3
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
0

tested on macOS
$ sudo sh -c 'for i in $(seq 1 500); do ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
       0

[1]https://travis-ci.org/github/karelzak/util-linux/jobs/723642222#L3907

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
4 years agolibfdisk: reset context FD on error
yangzz-97 [Sun, 6 Sep 2020 10:30:48 +0000 (18:30 +0800)] 
libfdisk: reset context FD on error

When the query disk fails, reset cxt->dev_fd.

Addresses: https://github.com/karelzak/util-linux/pull/1137
Addresses: https://github.com/karelzak/util-linux/issues/1131
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibsmartcols: don't print empty output on empty table in JSON
Karel Zak [Mon, 7 Sep 2020 09:52:13 +0000 (11:52 +0200)] 
libsmartcols: don't print empty output on empty table in JSON

old version:
 $ findmnt --json --type foo
 $

new version:
 $ findmnt --json --type foo
 {
    "filesystems": [
    ]
 }

Addresses: https://github.com/karelzak/util-linux/issues/1136
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agomount: Add support for "nosymfollow" mount option.
Mattias Nissler [Thu, 17 Nov 2016 13:47:51 +0000 (14:47 +0100)] 
mount: Add support for "nosymfollow" mount option.

This adds support for the "nosymfollow" mount option, which indicates
that symlinks should not be traversed on the mount this option is
applied to.  Also update the mount(8) man page with information about
this option.

Signed-off-by: Mattias Nissler <mnissler@chromium.org>
Signed-off-by: Ross Zwisler <zwisler@google.com>
4 years agoMerge branch 'cramfs-test-fix' of https://github.com/masami256/util-linux
Karel Zak [Thu, 3 Sep 2020 08:57:13 +0000 (10:57 +0200)] 
Merge branch 'cramfs-test-fix' of https://github.com/masami256/util-linux

* 'cramfs-test-fix' of https://github.com/masami256/util-linux:
  tests: mkfs-endianness test use iflag=fullblock to fill block completely with string

4 years agotests: mkfs-endianness test use iflag=fullblock to fill block completely with string
Masami Ichikawa [Thu, 3 Sep 2020 01:04:36 +0000 (10:04 +0900)] 
tests: mkfs-endianness test use iflag=fullblock to fill block completely with string

When run mkfs-endianness test on lowend machine, sometimes dd didn't
fill block with string then test failed.
So, it's nice to add iflag=fullblock option to fill a block with
string read from stdin.

Tested on Raspberry Pi 3 B+(using 1core to simulate lowend environment)
 with iflag=fullblock option didn't get test failure.

Without iflag=fullblock option.
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
49

With iflag=fullblock option.
$ sudo sh -c 'for i in $(seq 1 500); do taskset -c 0 ./ts/cramfs/mkfs-endianness ;  done' | grep FAILED | wc -l
0

Signed-off-by: Masami Ichikawa <masami256@gmail.com>
4 years agolibmount: do not use pointer as an integer value
Sami Kerola [Fri, 28 Aug 2020 19:59:57 +0000 (20:59 +0100)] 
libmount: do not use pointer as an integer value

Fix couple "initialization of ‘long int’ from ‘void *’ makes integer from
pointer without a cast" warnings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
4 years agolsblk: fix -T optional argument
Karel Zak [Wed, 2 Sep 2020 09:10:18 +0000 (11:10 +0200)] 
lsblk: fix -T optional argument

Addresses: https://github.com/karelzak/util-linux/issues/1132
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agopg: fix wcstombs() use
Karel Zak [Tue, 1 Sep 2020 09:50:11 +0000 (11:50 +0200)] 
pg: fix wcstombs() use

The size (3rd) argument should be ignored if the 1st *dest is NULL, but it seems gcc & glibc headers
are more pedantic now:

ext-utils/pg.c:456:13: error: argument 1 is null but the corresponding size argument 3 value is 2048 [-Werror=nonnull]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolibmount: remove read-mountinfo workaround
Karel Zak [Tue, 1 Sep 2020 08:15:14 +0000 (10:15 +0200)] 
libmount: remove read-mountinfo workaround

This workaround has been introduced by
http://github.com/karelzak/util-linux/commit/e4925f591c1bfb83719418b56b952830d15b77eb

And originally requested by https://github.com/systemd/systemd/issues/10872

It seems we do not need it anymore as the problem should be fixed in kernel since 5.8
(kernel commit 9f6c61f96f2d97cbb5f7fa85607bc398f843ff0f).

Note that the libmount solution is very expensive as it repeats read()
many times (until we get consistent result) if kernel is busy with
mount table modification. This behaviour makes events management in
systemd (or other places) pretty difficult as read mountinfo takes
time on busy systems.

Addresses: https://github.com/systemd/systemd/pull/16537
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'master' of https://github.com/itsthem/util-linux
Karel Zak [Tue, 1 Sep 2020 07:45:32 +0000 (09:45 +0200)] 
Merge branch 'master' of https://github.com/itsthem/util-linux

* 'master' of https://github.com/itsthem/util-linux:
  her -> their
  her -> their
  him -> them
  him -> them
  his -> their
  he -> they
  he -> they
  he -> they

4 years agohwclock: fix SYS_settimeofday fallback
Rosen Penev [Sun, 30 Aug 2020 04:55:58 +0000 (21:55 -0700)] 
hwclock: fix SYS_settimeofday fallback

turns out this is subtly broken. musl 1.2.x for 64-bit architectures defines __NR_settimeofday but not
for 32-bit ones. For 32-bit, it defines a _time32 variant.

4 years agoher -> their
leeceeksdee [Fri, 28 Aug 2020 17:19:23 +0000 (19:19 +0200)] 
her -> their

4 years agoher -> their
leeceeksdee [Fri, 28 Aug 2020 17:18:33 +0000 (19:18 +0200)] 
her -> their

4 years agohim -> them
leeceeksdee [Fri, 28 Aug 2020 17:17:00 +0000 (19:17 +0200)] 
him -> them

4 years agohim -> them
leeceeksdee [Fri, 28 Aug 2020 17:16:33 +0000 (19:16 +0200)] 
him -> them

4 years agohis -> their
leeceeksdee [Fri, 28 Aug 2020 17:15:34 +0000 (19:15 +0200)] 
his -> their

4 years agohe -> they
leeceeksdee [Fri, 28 Aug 2020 17:12:44 +0000 (19:12 +0200)] 
he -> they

4 years agohe -> they
leeceeksdee [Fri, 28 Aug 2020 17:11:45 +0000 (19:11 +0200)] 
he -> they

4 years agohe -> they
leeceeksdee [Fri, 28 Aug 2020 17:11:02 +0000 (19:11 +0200)] 
he -> they

4 years agoManual pages: blockdev.8, sfdisk.8: typo fixes
Michael Kerrisk (man-pages) [Thu, 27 Aug 2020 15:12:45 +0000 (17:12 +0200)] 
Manual pages: blockdev.8, sfdisk.8: typo fixes

Fix a couple of typos that I introduced.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
4 years agoscript: cleanup --echo
Soumendra Ganguly [Thu, 27 Aug 2020 09:50:25 +0000 (11:50 +0200)] 
script: cleanup --echo

Permanently turn off current stdin ECHO when it is a terminal and enable setting slave ECHO instead.
Fix other minor typos, update documentation.

[kzak@redhat.com: - remove irrelevant changes
                  - keep --echo argument unchanged]

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agobash-completion: add column --table-columns-limit
Karel Zak [Tue, 25 Aug 2020 12:23:28 +0000 (14:23 +0200)] 
bash-completion: add column --table-columns-limit

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agocolumn: add --table-columns-limit
Karel Zak [Tue, 25 Aug 2020 12:15:36 +0000 (14:15 +0200)] 
column: add --table-columns-limit

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':'
AAA  BBB  CCC  DDD

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':' -l 2
AAA  BBB:CCC:DDD

$ echo -e 'AAA:BBB:CCC:DDD\n' | ./column -t -s ':' -l 3
AAA  BBB  CCC:DDD

Addresses: https://github.com/karelzak/util-linux/issues/1124
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMerge branch 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux
Karel Zak [Tue, 25 Aug 2020 09:29:16 +0000 (11:29 +0200)] 
Merge branch 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux

* 'fix-sfdisk-json' of https://github.com/adriaandegroot/util-linux:
  Generate valid JSON if partition table is empty

4 years agomount, umount: restore environ[] after suid drop
Karel Zak [Tue, 25 Aug 2020 08:48:29 +0000 (10:48 +0200)] 
mount, umount: restore environ[] after suid drop

The commands mount and umount sanitize environment variables as it
works with suid permissions by default. Since v2.36 it's possible
that the commands drop the permissions and continue as regular user.
It seems we also need to restore the original environ to keep things
consistent for users (e.g. HOME=).

The implementation is pretty simple -- it keeps in memory removed
variables and use it after switch to non-suid mode.

Addresses: https://github.com/karelzak/util-linux/issues/880
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agolib/env: add function to save and restore unwanted variables
Karel Zak [Tue, 25 Aug 2020 08:43:07 +0000 (10:43 +0200)] 
lib/env: add function to save and restore unwanted variables

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoGenerate valid JSON if partition table is empty
Adriaan de Groot [Mon, 24 Aug 2020 21:30:35 +0000 (23:30 +0200)] 
Generate valid JSON if partition table is empty

When the partition table is present **but** empty, the existing code would output fields followed by a `,` , on the assumption that the list of partitions would follow. But if the list of partitions is empty, it is skipped, leading to output like this:

```
{
  "partitiontable": {
      "label":"gpt",
      "id":"1F9E80D9-DD78-024F-94A3-B61EC82B18C8",
      "device":"/dev/sdb",
      "unit":"sectors",
      "firstlba":2048,
      "lastlba":30949342,
      "sectorsize":512,
  }
}
```

Note the `512,` on the *sectorsize* line.

This is invalid JSON for some parsers, which choke on it.

Avoid this, by checking when outputting the last separator: if there's no table, or there is a table but it is empty, then just put a newline, otherwise use the old path of comma-newline and assume there's going to be a list of partitions after.

4 years agolibfdisk: add systemd-homed user's home GPT partition type
nl6720 [Sat, 22 Aug 2020 12:16:27 +0000 (15:16 +0300)] 
libfdisk: add systemd-homed user's home GPT partition type

See https://systemd.io/HOME_DIRECTORY/ .
Additionally update the URL of the Boot Loader Specification.

Signed-off-by: nl6720 <nl6720@gmail.com>
4 years agolibmount: fix tab parser for badly terminated lines
Karel Zak [Mon, 17 Aug 2020 14:33:59 +0000 (16:33 +0200)] 
libmount: fix tab parser for badly terminated lines

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agotests: cover the code parsing comments
Evgeny Vereshchagin [Thu, 13 Aug 2020 05:20:14 +0000 (05:20 +0000)] 
tests: cover the code parsing comments

It seems to be failing with
```
AddressSanitizer:DEADLYSIGNAL
=================================================================
==13==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000055f428 bp 0x7ffc3743a170 sp 0x7ffc3743a080 T0)
==13==The signal is caused by a WRITE memory access.
==13==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x55f428 in mnt_table_parse_next /src/util-linux/libmount/src/tab_parse.c:587:6
    #1 0x55c200 in __table_parse_stream /src/util-linux/libmount/src/tab_parse.c:737:8
    #2 0x55be38 in mnt_table_parse_stream /src/util-linux/libmount/src/tab_parse.c:809:8
    #3 0x5511ff in LLVMFuzzerTestOneInput /src/util-linux/libmount/src/fuzz.c:21:16
    #4 0x458a31 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:558:15
    #5 0x458175 in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:470:3
    #6 0x45a117 in fuzzer::Fuzzer::ReadAndExecuteSeedCorpora(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:770:7
    #7 0x45a319 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, fuzzer::fuzzer_allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:799:3
    #8 0x44a055 in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:846:6
    #9 0x471bf2 in main /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerMain.cpp:19:10
    #10 0x7fe3bd93b83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #11 0x41f208 in _start (/out/test_mount_fuzz+0x41f208)

DEDUP_TOKEN: mnt_table_parse_next--__table_parse_stream--mnt_table_parse_stream
```

4 years agoMerge branch 'patch-1' of https://github.com/8vasu/util-linux
Karel Zak [Fri, 14 Aug 2020 09:18:59 +0000 (11:18 +0200)] 
Merge branch 'patch-1' of https://github.com/8vasu/util-linux

* 'patch-1' of https://github.com/8vasu/util-linux:
  Update pty-session.c
  More minor typos
  Fix minor typo

4 years agoMerge branch 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux
Karel Zak [Fri, 14 Aug 2020 09:16:12 +0000 (11:16 +0200)] 
Merge branch 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux

* 'fdisk-fuzzer-follow-up' of https://github.com/evverx/util-linux:
  tests: add testcases that triggered various crashes

4 years agolibfdisk: (script) fix possible partno overflow
Karel Zak [Fri, 14 Aug 2020 09:13:50 +0000 (11:13 +0200)] 
libfdisk: (script) fix possible partno overflow

Addresses: https://oss-fuzz.com/testcase-detail/5740890480705536
Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoUpdate pty-session.c
Soumendra Ganguly [Thu, 13 Aug 2020 17:58:22 +0000 (12:58 -0500)] 
Update pty-session.c

4 years agolibfdisk: (script) fix possible memory leaks
Karel Zak [Thu, 13 Aug 2020 11:48:28 +0000 (13:48 +0200)] 
libfdisk: (script) fix possible memory leaks

Signed-off-by: Karel Zak <kzak@redhat.com>
4 years agoMore minor typos
Soumendra Ganguly [Thu, 13 Aug 2020 11:01:57 +0000 (06:01 -0500)] 
More minor typos

4 years agolibfdisk: another parse_line_nameval() cleanup
Karel Zak [Thu, 13 Aug 2020 08:13:01 +0000 (10:13 +0200)] 
libfdisk: another parse_line_nameval() cleanup

4 years agolibfdisk: make fdisk_partname() more robust
Karel Zak [Thu, 13 Aug 2020 08:12:01 +0000 (10:12 +0200)] 
libfdisk: make fdisk_partname() more robust

4 years agoFix minor typo
Soumendra Ganguly [Thu, 13 Aug 2020 07:44:28 +0000 (02:44 -0500)] 
Fix minor typo

terminall -> terminal