Sami Kerola [Wed, 18 Mar 2020 20:12:54 +0000 (20:12 +0000)]
more: do not allocate shell command buffer from stack
This change has three possitive effects: Avoid expansion code when it is
not needed. Stop wasting memory from stack for something rarely needed.
When command buffer is needed stop limiting it's size artificially.
Sami Kerola [Wed, 18 Mar 2020 20:12:51 +0000 (20:12 +0000)]
more: replace siglongjmp() and signal() calls with signalfd()
From man siglongjmp(3) 'longjmp() and siglongjmp() make programs hard to
understand and maintain. If possible, an alternative should be used.' That
manual page remark summarizes quite well why more(1) needs to move away from
jumping around.
Damien Le Moal [Thu, 26 Mar 2020 10:27:50 +0000 (11:27 +0100)]
blkzone: ioctl related code refactoring
[kzak@redhat.com: - generate patch from Damien's v3
- make commands[] initialization more robust]
Signed-off-by: Aravind Ramesh <Aravind.Ramesh@wdc.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Aravind Ramesh [Tue, 24 Mar 2020 10:02:17 +0000 (19:02 +0900)]
blkzone: add open/close/finish commands
Introduce blkzone open, close and finish commands, issuing BLKOPENZONE,
BLKCLOSEZONE and BLKFINISHZONE ioctl commands to open, close or finish
a range of zones of a zoned block device.
Since these three commands are similar to the existing zone reset
command, the existing zone reset command implementation is changed into
the generic blkzone_action() internal handler function for processing
all zone actions.
The BLKOPENZONE, BLKCLOSEZONE and BLKFINISHZONE ioctl commands codes are
defined in linux/blkzoned.h starting with kernel version 5.5. To ensure
that the blkzone utility compiles even with older blkzoned.h kernel
header versions, these ioctl commands are internally defined if the
blkzoned.h header definition is not present. Execution of these commands
on kernels older than 5.5 will result in a -ENOTTY error (missing
ioctl).
Signed-off-by: Aravind Ramesh <Aravind.Ramesh@wdc.com> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Tested-by: Hans Holmberg <Hans.Holmberg@wdc.com> Reviewed-by: Hans Holmberg <Hans.Holmberg@wdc.com>
Karel Zak [Tue, 24 Mar 2020 10:17:34 +0000 (11:17 +0100)]
fdisk: add --noauto-pt
The default partition table depends on system arch, for example on
Sparc it's SUN and on x86_64 it's MBR. This option forces fdisk to
keep the device empty and allow user to create non-default PT in more
elegant way.
Addresses: https://github.com/karelzak/util-linux/pull/994 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 23 Mar 2020 11:14:57 +0000 (12:14 +0100)]
Merge branch 'eject-sparc' of https://github.com/mator/util-linux
* 'eject-sparc' of https://github.com/mator/util-linux:
tests: fixes mount tests on SPARC
tests: fixes libmount/ on SPARC
tests: fixes eject/umount on SPARC
Damien Le Moal [Fri, 20 Mar 2020 04:55:43 +0000 (13:55 +0900)]
libblkid: Add support for zonefs
The zonefs filesystem was added to upstream linux kernel 5.6. This
patch add support for probing zonefs formatted zoned block devices so
that other file system formatting tool can detect its presence on a
device.
[kzak@redhat.com: - use standard integer types]
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sun, 22 Mar 2020 09:37:41 +0000 (09:37 +0000)]
docs: kill.1 add note about shell-internal kill implementations
Requested-by: Ilia Baryshnikov <qwelias@gmail.com>
Reference: https://github.com/karelzak/util-linux/issues/991#issuecomment-602108648 Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Anatoly Pugachev [Tue, 10 Mar 2020 16:16:01 +0000 (19:16 +0300)]
tests: fixes eject/umount on SPARC
Since SPARC is using 'sun' partition table by default, make test not to
assume that disk has 'dos' partition table, so write 'dos' partition
table on disk, before proceeding any further.
Adrian Reber [Mon, 9 Mar 2020 13:02:45 +0000 (13:02 +0000)]
nsenter: add support for the time namespace
Just as with unshare and lsns this adds time namespace support to
nsenter.
In contrast to unshare nsenter does not have the options '--boottime'
and '--monotonic' as that offset can only be set as long as there have
no processes being started in the corresponding time namespace.
Adrian Reber [Mon, 9 Mar 2020 12:20:51 +0000 (12:20 +0000)]
unshare: use '-T' for time namespace instead of '-t'
While working on getting time namespace support into 'nsenter' it was
not possible to use '-t' to enter a time namespace as '-t' is the short
option for '--target'. Fortunately '-T' is still available in 'nsenter'
and 'unshare' and therefore let's change 'unshare' to use the same flag
for the time namespace as 'nsenter'.
Adrian Reber [Fri, 6 Mar 2020 11:05:00 +0000 (12:05 +0100)]
unshare: support the time namespace
This adds support to unshare for time namespaces. With the newly added
options '-t, --time' and '--monotonic' and '--boottime' it is now
possible to change CLOCK_MONOTONIC and CLOCK_BOOTTIME in a new time
namespace.
The time namespace has been merged in kernel version 5.6 and an easy way
to test it is using CLOCK_BOOTTIME and the uptime command:
Adrian Reber [Fri, 6 Mar 2020 11:03:50 +0000 (12:03 +0100)]
unshare: fix help message indentation
A few lines of the help message were unaligned in the output because of
mixes use of tabs and space. This removes all tabs and replaces them
with spaces.
Sami Kerola [Fri, 6 Mar 2020 20:14:06 +0000 (20:14 +0000)]
lsirq: mark --json and --pairs options mutually exclusive
Before this change --pairs option would always win over --json. That is
unnecessarily confusing, it is much better to disallow combination that does
not make sense.
Notice that the --noheadings in combination with --json or --pairs will not
cause any effect. In strictest possible understanding --noheadings should
also be exclusive. Looking from more relaxed point of view neither --json
nor --pairs has heading, so excluding is not necessary because --noheading
is happening already.
Karel Zak [Fri, 6 Mar 2020 14:28:57 +0000 (15:28 +0100)]
irqtop: cleanup sort stuff
* user "cmp" in the function names (it does not sort)
* keep all in irq-common.c
* use column names on command line (e.g. --sort NAME)
* hardcode default to sort_result()
Karel Zak [Tue, 3 Mar 2020 15:10:02 +0000 (16:10 +0100)]
fdisk: add support for parttype aliases
* add list of supported aliases to 'l' and 'L' output
* support aliases in 't' dialog
For example (use 'swap' to set 0x82 partition type):
Command (m for help): t
Selected partition 1
Hex code or alias (type L to list all): swap
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Note that the aliases are evaluated as the last possibility if user's
input dues not match up with any partition type. This is necessary for
backward compatibility.
This patch does NOT introduce shortcuts (.e.g. 'S' for swap) to
fdisk(8) due to collisions with already used dialog keys.
Addresses: https://github.com/karelzak/util-linux/issues/958 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 3 Mar 2020 15:07:00 +0000 (16:07 +0100)]
sfdisk: extend --part-type, support aliases
* add support for aliases to sfdisk scripts
* add shortcuts and aliases to --part-type command
Note that --part-type evaluates shortcuts and aliases as the last
possibility (so after regular type string). This is necessary for
backward compatibility.
Example ('raid' type alias):
# sfdisk --part-type /dev/sdc 1 raid
# fdisk -l /dev/sdc
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 204799 202752 99M fd Linux raid autodetect
Example ('L' type shortcut):
# sfdisk --part-type /dev/sdc 1 L
# fdisk -l /dev/sdc
...
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 204799 202752 99M 83 Linux
Addresses: https://github.com/karelzak/util-linux/issues/958 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 3 Mar 2020 14:59:49 +0000 (15:59 +0100)]
libfdisk: add partition type aliases and shortcuts
Now, the type shortcuts are supported for sfdisk scripts only.
Unfortunately, the current implementation is not generic enough
and it's also fragile as 'E' shortcut is in collision with 0x0E
type for MBR. The another issue is 'L' which makes shortcuts useless
for fdisk where 'L' is used for another purpose in dialogs.
This patch introduces partition type aliases as extension to
shortcuts. The definition of the shortcut is part of the label
definition and it's not more hardcoded in sfdisk script code.
This patch also introduces 'Ex' shortcut as replacement for (now
deprecated) 'E'.
Karel Zak [Mon, 2 Mar 2020 13:41:39 +0000 (14:41 +0100)]
sfdisk: fix previous --append patch, improve man page
- fix stupid typo (!has_container_or_unused(sf))
- use fdisk_is_partition_used() as fdisk_get_partition() returns
nothing for unused partition
- update tests
- add more hints to the man page
Addresses: https://github.com/calamares/calamares/issues/1332 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Mon, 2 Mar 2020 11:27:36 +0000 (12:27 +0100)]
sfdisk: fix --append to PT with gaps
sfdisk trying to be more smart than libfdisk when analyze if we can
append to the current PT. libfdisk is able to use unused partition
to create a new one (if partno not strictly specified), but sfdisk
assumes that we can add partition to extended partition only.
Addresses: https://github.com/calamares/calamares/issues/1332 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 25 Feb 2020 14:31:23 +0000 (15:31 +0100)]
lsblk: fix -P regression from v2.34
Since v2.34 --list prints devices only once to make the output
user-readable. Unfortunately, it's regression for scripts/applications
where we need to parse lsblk output. So, let's make --pairs and --raw
backwardly compatible with versions before 2.34 and print all hierarchy.
Addresses: https://github.com/ibm-s390-tools/s390-tools/issues/80 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 25 Feb 2020 11:06:06 +0000 (12:06 +0100)]
libblkid: fix compiler warning [-Wsign-compare]
libblkid/src/superblocks/exfat.c: In function ‘probe_exfat’:
./include/c.h:133:17: warning: comparison of distinct pointer types lacks a cast
libblkid/src/superblocks/exfat.c:129:5: note: in expansion of macro ‘min’
./include/c.h:134:8: warning: comparison of integer expressions of different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]