Commit Graph

14674 Commits

Author SHA1 Message Date
Karel Zak 8deb45fc56 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>
2020-09-21 12:58:46 +02:00
Soumendra Ganguly 5c6903b159 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>
2020-09-21 12:58:15 +02:00
Karel Zak 39d16258a1 docs: add note about github
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-15 09:01:13 +02:00
Gero Treuner 23fcac0457 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>
2020-09-14 12:03:50 +02:00
Karel Zak 93b23ce420 Merge branch 'addCarmelLscpu' of https://github.com/tomoaki0705/util-linux
* 'addCarmelLscpu' of https://github.com/tomoaki0705/util-linux:
  add Carmel from NVIDIA
2020-09-14 10:49:28 +02:00
Sami Kerola 81c9867d18
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>
2020-09-12 23:20:18 +01:00
Sami Kerola 86c6d3ff68
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>
2020-09-12 23:19:16 +01:00
Sami Kerola 3375fd9ccf
col: tidy up sources a little bit
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-12 18:32:55 +01:00
Sami Kerola 12234f462a
col: add defaults to switch case clauses
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-12 18:32:55 +01:00
Sami Kerola e15ed08756
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>
2020-09-12 18:32:54 +01:00
Sami Kerola 8f36d39294
col: use size_t when dealing with numbers that buffer sizes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-12 18:31:05 +01:00
Sami Kerola 0148d75bcd
col: add structure to hold line variables
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-12 18:27:13 +01:00
Sami Kerola 812e849eac
col: add update_cur_line() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-12 18:27:13 +01:00
Sami Kerola 6591d3bd6b
col: add handle_not_graphic() function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-12 18:27:13 +01:00
Sami Kerola d38392a1e8
col: initialize variables when they are declared
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-11 20:55:02 +01:00
Sami Kerola 9f60a69217
col: move option handling to separate function
Mark --tabs and --spaces mutually exclusive in same go.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-11 20:55:02 +01:00
Sami Kerola 31a61cbedc
col: move global variables to a control structure
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-11 20:55:02 +01:00
Sami Kerola fd8270b4f2
col: use inline function rather than function like define
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-11 20:55:02 +01:00
Sami Kerola 6c5a421e09
col: use typedef and enum to clarify struct
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-11 20:55:02 +01:00
Sami Kerola f5ab4ee375
col: remove function prototypes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-09-11 20:55:02 +01:00
Sami Kerola b97981a707
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>
2020-09-11 20:55:01 +01:00
Tomoaki Teshima 793378dfc9 add Carmel from NVIDIA 2020-09-11 22:45:54 +09:00
Hans Holmberg 049859a6df 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>
2020-09-11 12:28:19 +02:00
Thayne McCombs df09e21c24 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>
2020-09-11 12:20:37 +02:00
Karel Zak 701f0385a0 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>
2020-09-10 12:54:14 +02:00
Karel Zak e270d980ca mkswap: cleanup usage()
- don't use one string for all --help output
- use USAGE_* macros

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-10 11:26:18 +02:00
Karel Zak 199cd674ad 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>
2020-09-09 15:50:39 +02:00
Karel Zak 29b68b9c7b 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>
2020-09-09 15:41:56 +02:00
Karel Zak c90a8f1a3c 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>
2020-09-09 14:50:02 +02:00
Karel Zak 14bb8e3ca6 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>
2020-09-09 12:23:33 +02:00
Karel Zak bb6c51a650 lsblk: print zero rather than empty SIZE
Addresses: https://github.com/karelzak/util-linux/issues/1118
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-09 12:00:10 +02:00
Karel Zak 549e8c91ff Merge branch 'cramfs-use-prepared-test-data' of https://github.com/masami256/util-linux 2020-09-09 11:23:48 +02:00
Karel Zak 50a531f667 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.
2020-09-09 11:13:34 +02:00
Karel Zak 195025c29e 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>
2020-09-09 11:10:51 +02:00
Masami Ichikawa 9c84873186 tests: mkfs-endianness test uses prepared test data
Commit 7b54f05d6b 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>
2020-09-09 09:10:58 +09:00
yangzz-97 933f095feb 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>
2020-09-07 12:09:36 +02:00
Karel Zak f29a2cfbe1 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>
2020-09-07 11:52:13 +02:00
Mattias Nissler 73b193f8da 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>
2020-09-03 10:52:33 -06:00
Karel Zak f9de18f54a 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
2020-09-03 10:57:13 +02:00
Masami Ichikawa 7b54f05d6b 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>
2020-09-03 10:41:18 +09:00
Sami Kerola f4987e082b 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>
2020-09-02 12:06:18 +02:00
Karel Zak 6932a11035 lsblk: fix -T optional argument
Addresses: https://github.com/karelzak/util-linux/issues/1132
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-02 11:10:18 +02:00
Karel Zak 42fa381b9d 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>
2020-09-01 11:54:07 +02:00
Karel Zak 57898c3a7e libmount: remove read-mountinfo workaround
This workaround has been introduced by
e4925f591c

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>
2020-09-01 10:15:14 +02:00
Karel Zak a3a0cc42af 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
2020-09-01 09:45:32 +02:00
Rosen Penev fdac67ae14
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.
2020-08-29 21:55:58 -07:00
leeceeksdee 0c4bf7913c
her -> their 2020-08-28 19:19:23 +02:00
leeceeksdee c9c7de7932
her -> their 2020-08-28 19:18:33 +02:00
leeceeksdee 087203733d
him -> them 2020-08-28 19:17:00 +02:00
leeceeksdee 3a03903011
him -> them 2020-08-28 19:16:33 +02:00