Commit Graph

14338 Commits

Author SHA1 Message Date
Sami Kerola b6818219fb
more: move runtime usage output to a function
This change also removes a ghost prompt that was left in place when printing
help.  When looking old commits the output fluke has been around at least
since util-linux v2.2.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-28 07:55:58 +00:00
Sami Kerola f53edc0ee6
more: restructure print_buf() if-else with continue
Replacing long 'else' with 'continue' allows dropping one level of
indentation.  Main aim is to improve code readability by reducing
complexity one needs to keep track while looking the code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-28 07:55:58 +00:00
Sami Kerola f8492042f5
more: tell in run time help what the 'v' will execute as editor
In same go use well known paths from system include file.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-28 07:55:58 +00:00
Sami Kerola 8fb5fe304a
more: drop setuid permissions before executing anything
Pagers are not expected to have setuid or setgid bits, but assuming such
mistake has taken place try to avoid privilege escalation.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-28 07:55:58 +00:00
Jiaxun Yang 6cb8af7be2 lscpu: Adapt MIPS cpuinfo
MIPS have slightly different layout of cpuinfo.

Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
2020-03-28 12:19:42 +08:00
Sami Kerola 474c61c0a8
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-27 21:06:08 +00:00
Sami Kerola 823ef319b6
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-03-27 21:06:01 +00:00
Karel Zak a971746370 libmount: make mnt_context_find_umount_fs() more extendable
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-27 11:34:12 +01:00
Karel Zak 4ce77c625a libmount: (umount) FS lookup refactoring
Let's split lookup to more function to make it easy to add another
lookup method.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-27 11:10:26 +01:00
Damien Le Moal 46cf662532 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>
2020-03-26 11:27:50 +01:00
Aravind Ramesh 0cecae9c03 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>
2020-03-25 12:27:13 +01:00
Karel Zak e7db499f1c tests: cleanup fdisk based stuff
* use fdisk --noauto-pt to avoid re-creation of the default architecture specific PT
* use more verbose "Created a new" messages in the output

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 14:30:16 +01:00
Karel Zak 53a808562d fdisk: make sure label defined for some menu entries
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 12:00:28 +01:00
Karel Zak f2229320a9 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>
2020-03-24 11:17:34 +01:00
Karel Zak ca6e434a7d libfdisk: remove unwanted assert()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-24 10:52:54 +01:00
Karel Zak f3c90e9172 Revert "tests: fixes fdisk/align-512-* tests"
This reverts commit 25f5c514b9.
2020-03-24 10:48:55 +01:00
Karel Zak 6d9c158873 Merge branch 'fdisk-sparc' of https://github.com/mator/util-linux
* 'fdisk-sparc' of https://github.com/mator/util-linux:
  tests: fixes fdisk/align-512-* tests
2020-03-23 16:35:32 +01:00
Anatoly Pugachev 25f5c514b9 tests: fixes fdisk/align-512-* tests
write 'MSDOS' partition table before test

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
2020-03-23 17:23:01 +03:00
Karel Zak ba481a28a8 libblkid: remove unnecessary uuid.h
Addresses: https://github.com/karelzak/util-linux/issues/993
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-23 15:21:48 +01:00
Karel Zak 5c52c75803 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
2020-03-23 12:14:57 +01:00
Damien Le Moal 9d691cbc94 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>
2020-03-23 11:27:16 +01:00
Karel Zak 6cc3a256c4 Merge branch 'man-kill' of https://github.com/kerolasa/util-linux
* 'man-kill' of https://github.com/kerolasa/util-linux:
  docs: kill.1 add note about shell-internal kill implementations
2020-03-23 10:28:16 +01:00
Karel Zak d044e49f1b Merge branch 'libfdisk-script-fix-segmentation-fault' of https://github.com/gportay/util-linux
* 'libfdisk-script-fix-segmentation-fault' of https://github.com/gportay/util-linux:
  lib/mangle: check for the NULL string argument
  libfdisk: (script) fix segmentation fault
2020-03-23 10:27:53 +01:00
Sami Kerola 735fd5ed2b
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>
2020-03-22 09:37:41 +00:00
Gaël PORTAY e368d0ad5d lib/mangle: check for the NULL string argument
This patch prevents to call the function strlen() with a NULL string
argument that leads to a segmentation fault.

Signed-off-by: Gaël PORTAY <gael.portay@collabora.com>
2020-03-20 16:28:49 -04:00
Gaël PORTAY 3468dda9c3 libfdisk: (script) fix segmentation fault
This patch fixes a segmentation fault that occurs if the name value is
empty (i.e. name=).

Signed-off-by: Gaël PORTAY <gael.portay@collabora.com>
2020-03-20 16:28:33 -04:00
Mark Barbone 9a7dc84118
Fix typo in the mount (8) man page 2020-03-19 18:13:46 -04:00
Karel Zak f205a07363 build-sys: fix chfn-chsh configure help text
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-16 10:53:55 +01:00
Karel Zak 36d80cb6c1 libmount: smb2 is unsupported alias
Kenneth D'souza wrote:
 # grep -w MODULE_ALIAS_FS fs/cifs/cifsfs.c
 MODULE_ALIAS_FS("cifs");
 112/112│MODULE_ALIAS_FS("smb3");

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1812118
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-11 18:38:09 +01:00
Anatoly Pugachev d4dc0fcf83 tests: fixes mount tests on SPARC
fdisk partition table fix for writting "msdos" label before the test

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
2020-03-11 17:22:21 +03:00
Anatoly Pugachev 356ed88a56 tests: fixes libmount/ on SPARC
fdisk partition table fix for writting "msdos" label before test

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
2020-03-11 17:22:21 +03:00
Anatoly Pugachev f97c20f4a4 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.

Signed-off-by: Anatoly Pugachev <matorola@gmail.com>
2020-03-11 17:22:21 +03:00
Karel Zak b7ff4134be libmount: improve smb{2,3} support
It seems kernel can use smb3 as fstype in mountinfo.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1812118
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-11 10:47:52 +01:00
Karel Zak a775c4a4a4 agetty: (man) fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 20:55:00 +01:00
Karel Zak 14e7e40314 agetty: (man) add "white" color name
Addresses: https://github.com/karelzak/util-linux/issues/979
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 12:33:35 +01:00
Karel Zak 0a4035ff2e include: cleanup pidfd inckudes
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 12:32:36 +01:00
Zbigniew Jędrzejewski-Szmek d52786aab7 fsck.cramfs: fix macro usage
Autotoolz does not define HAVE_LCHOWN when the condition is false,
so it is appropriate to use #ifdef/#ifndef as everywhere else.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 10:55:01 +01:00
Zbigniew Jędrzejewski-Szmek ac660b80fd build-sys: rename automake variable to match define name
Just to make things a bit more consistent.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 10:53:15 +01:00
Zbigniew Jędrzejewski-Szmek 2f8bfcccf1 build-sys: remove unneeded include of generated file
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 10:52:08 +01:00
Karel Zak 53829df2e3 lib/color-names: add "white" between human-readable
Addresses: https://github.com/karelzak/util-linux/issues/979
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-10 09:45:33 +01:00
Karel Zak 8797cb31b9 Merge branch 'nsenter' of https://github.com/adrianreber/util-linux 2020-03-10 09:40:34 +01:00
Adrian Reber 7f1f0584c2
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.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-03-10 07:46:37 +01:00
Adrian Reber f218fd9784
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'.

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-03-09 13:26:28 +01:00
Karel Zak 40c28f51c9 docs: add rev(1) to TODO
Addresses: https://github.com/karelzak/util-linux/issues/972
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-09 11:07:48 +01:00
Karel Zak 5b9b6d2a74 rev: (man) add note about limitations
Addresses: https://github.com/karelzak/util-linux/issues/972
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-09 11:03:30 +01:00
Karel Zak c2e82a4aaa hexdump: fix typo, dcl instead of dc1
Addresses: https://github.com/karelzak/util-linux/issues/976
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-09 10:54:28 +01:00
Karel Zak ef0341c9be Merge branch 'time-namespace' of https://github.com/adrianreber/util-linux
* 'time-namespace' of https://github.com/adrianreber/util-linux:
  unshare: support the time namespace
  unshare: fix help message indentation
2020-03-09 10:31:45 +01:00
Karel Zak d99d822d6e Merge branch 'lsns' of https://github.com/adrianreber/util-linux
* 'lsns' of https://github.com/adrianreber/util-linux:
  lsns: add time namespace support
2020-03-09 10:29:32 +01:00
Karel Zak a8fe698c45 Merge branch 'topic/irq' 2020-03-09 10:25:48 +01:00
Adrian Reber 96dc4f800d
lsns: add time namespace support
# ./lsns -t time
         NS TYPE  NPROCS   PID USER COMMAND
 4026531834 time     102     1 root /usr/lib/systemd/systemd --switched-root --system --deserialize 29
 4026532246 time       1 54797 root sleep 1000

Signed-off-by: Adrian Reber <areber@redhat.com>
2020-03-09 10:19:50 +01:00