Commit Graph

14255 Commits

Author SHA1 Message Date
Karel Zak e441601563 Merge branch 'topic/fdisk' 2020-03-03 16:22:10 +01:00
Karel Zak 006607abb5 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>
2020-03-03 16:20:05 +01:00
Karel Zak 5839a4ea03 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>
2020-03-03 16:15:39 +01:00
Karel Zak f94e753b35 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'.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 15:59:49 +01:00
Karel Zak 11b916cdab libmount: try read-only mount on write-protected superblock too
The classic mount(8) behavior is to try read-only on write-protected devices
if the first mount syscall attempt ends with EACCES.

It seems we can implement this feature also for EBUSY if the same mount source
is already mounted with "ro" superblock option.

The typical use-case is iso image (always read-only) mounted on two places.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1809124
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 11:39:10 +01:00
Karel Zak acd229fc2a libmount: move "already mounted" code to separate function
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-03-03 10:55:28 +01:00
Karel Zak ac762ed71f 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>
2020-03-02 14:41:39 +01:00
Karel Zak fa3fface0f 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>
2020-03-02 12:27:36 +01:00
Karel Zak 940928c9f1 docs: add note about AsciiDocs
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 14:56:46 +01:00
Karel Zak 079dc9ddcd libuuid: add uuid_parse_range() to man page and symbol-table
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 14:52:06 +01:00
Karel Zak ef59d1908d Merge branch 'libuuid-range' of https://github.com/UQ-RCC/util-linux
* 'libuuid-range' of https://github.com/UQ-RCC/util-linux:
  libuuid: add uuid_parse_range()
2020-02-27 14:44:43 +01:00
Karel Zak 57b9d60cb5 su, runuser: (man) add more info about PATH and PAM
Addresses: https://github.com/karelzak/util-linux/issues/964
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 14:37:23 +01:00
Karel Zak 189edf1fe5 hwclock: fix audit exit status
According to audit_log_user_message(3) result 1 is "success" and 0 is
"failed", we use standard EXIT_{SUCCESS,FAILURE} macros with reverse
status.

Addresses: https://github.com/karelzak/util-linux/issues/966
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 14:04:55 +01:00
Karel Zak 1f47d4a2f0 chsh: (man) fix default behavior description
Addresses: https://github.com/karelzak/util-linux/issues/967
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 13:54:05 +01:00
Karel Zak c6d8486aad findmnt: make xalloc use mroe robust
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1807003
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-27 10:02:39 +01:00
Karel Zak 91b636b565 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>
2020-02-25 15:31:23 +01:00
Karel Zak ce8985cc71 libfdisk: (gpt) partition name default to empty string
Just for backward compatibility, otherwise it's strange ;-)

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 12:41:10 +01:00
Karel Zak f4189a087a libfdisk: add missing comments
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 12:25:17 +01:00
Karel Zak 487b57f58b libfdisk: use ul_encode_to_utf8()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 12:21:32 +01:00
Karel Zak 81826929eb 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]

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 12:06:06 +01:00
Karel Zak 35c6ed615f libblkid: move UTF encoding function to lib/
Let's consolidate the code, we need to use it in libfdisk too. It
seems better to keep it generic and libblkid independent.

This patch also removes blkid_encode_alloc(), this function is overkill.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-25 12:00:27 +01:00
Zane van Iperen e64a8f9cbf libuuid: add uuid_parse_range()
For compatibility with C++'s std::string_view, et al.

Signed-off-by: Zane van Iperen <z.vaniperen@uq.edu.au>
2020-02-25 15:22:49 +10:00
Sami Kerola ebdb0c350a
docs: remove irqtop TODO item
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-24 18:27:16 +00:00
Sami Kerola d7f9cdf535
irqtop: tidy coding style and update usage() text
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-24 18:26:38 +00:00
J William Piggott cd781c405b hwclock: make glibc 2.31 compatible
______________________________________________________
GNU C Library NEWS -- history of user-visible changes.
Version 2.31
Deprecated and removed features, and other changes affecting compatibility:

* The settimeofday function can still be used to set a system-wide time
  zone when the operating system supports it.  This is because the Linux
  kernel reused the API, on some architectures, to describe a system-wide
  time-zone-like offset between the software clock maintained by the kernel,
  and the "RTC" clock that keeps time when the system is shut down.

  However, to reduce the odds of this offset being set by accident,
  settimeofday can no longer be used to set the time and the offset
  simultaneously.  If both of its two arguments are non-null, the call
  will fail (setting errno to EINVAL).

  Callers attempting to set this offset should also be prepared for the call
  to fail and set errno to ENOSYS; this already happens on the Hurd and on
  some Linux architectures.  The Linux kernel maintainers are discussing a
  more principled replacement for the reused API.  After a replacement
  becomes available, we will change settimeofday to fail with ENOSYS on all
  platforms when its 'tzp' argument is not a null pointer.

  settimeofday itself is obsolescent according to POSIX.  Programs that set
  the system time should use clock_settime and/or the adjtime family of
  functions instead.  We may cease to make settimeofday available to newly
  linked binaries after there is a replacement for Linux's time-zone-like
  offset API.
______________________________________________________

hwclock(8) had one settimeofday(2) call where both args were set for
--hctosys when the RTC was ticking UTC. This allowed setting the system
time, timezone, and locking the warp_clock function with a single call.
That operation now takes 3 calls of settimeofday(2).

Although this common operation now takes three calls, the overall logic
for the set_system_clock() function was simplified.

Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: J William Piggott <elseifthen@gmx.com>
2020-02-24 16:45:32 +01:00
Karel Zak d5edb1003b umount: don't try it as non-suid if not found mountinfo entry
Addresses: https://github.com/karelzak/util-linux/issues/961
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-02-24 13:02:09 +01:00
Sami Kerola d77e9e13dd
irqtop: do not use fixed size /proc/interrupts line buffer
Allocating and freeing all the time is a little bit heavier, but it is also
more robust.  It is impossible to know if field lenghts stay fixed.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-23 17:36:33 +00:00
Sami Kerola 68afc56bcd
irqtop: add total and delta as own columns
This commit add total and delta as separate columns rather than a toggle,
making output generally more informative.  When using command I found that
sort order key bindings should match with first letter of column headers so
that they are as easy as possible to remember, and therefore enhancing user
experience.

Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-23 17:27:12 +00:00
Sami Kerola 28ddd62bed
irqtop: use name instead of desc as irq name field referal
This matches with sort order n for name, and allows later usage of d for
delta without needing to go around d for description.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola daee272009
irqtop: improve header
Change total to display delta or count depending on run mode.  Add space in
between header and irqtop body.  Print only number of active CPU in header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola bf611f4034
irqtop: hide cursor when in interactive mode
Visible cursor is distraction.  Secondly with visible cursor key commands
can be visible adding unwanted characters to end of output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola 11b20fb29d
irqtop: display number of new interupts in-between updates
The rirst output is total count followed by number of interupts since
previous screen update.  This is how the irqtop worked before libsmartcols
was added to the command.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola e11f242769
irqtop: add bash-completion
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola 050dc9f923
irqtop: add manual page
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:54 +00:00
Sami Kerola 8d8cef8045
irqtop: use libsmartcols
This makes output to be automatically be nicely adjusted to optimal width.
In this commit also removes excess spaces from description strings.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-22 21:43:40 +00:00
Sami Kerola a163d853c6
irqtop: include hostname and timestamp to output header
Having a when and from where information is useful in situations when output
is examined later and possibly elsewhere.  Typical example would be a
screenshot or output copy-paste of a terminal to a ticketing system.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:15 +00:00
Sami Kerola fa8c5cd503
irqtop: use epoll event loop
The event loop takes care of the standard screen updates, signals, and user
inputs.  Two nice things using even loop like this are; 1) no need for any
global variables and 2) effect of user commands is immediate.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:15 +00:00
Sami Kerola 29135b2320
irqtop: move screen update to a separate function
The main() was too long.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:15 +00:00
Sami Kerola bc90c16a78
irqtop: fix open file descriptor leak
With very short delay one can see irqfile file descriptors pile up rather
quickly causing program to stop with too many open files error.  This commit
fixes that, and removes couple other memory leaks.  With these the command
should hopefully run fine for days if not even months.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 4e55ffbdde
irqtop: change the update delay to use struct timeval
The struct timeval is more expressive, and it allows use of fractional and
subsecond intervals.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola a937ed0fd4
irqtop: use runtime control structure
This is pretty standard util-linux way to avoid global variables, and pass
runtime configuration around.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 465e279a26
irqtop: use lib/monotonic.c to determine uptime
This should be functionally the same, and has the advantage of avoiding
duplicated code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 9aea73b3ba
irqtop: use memory allocation that check errors
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola a11660d155
irqtop: avoid function like pre-processor definitions
And simplify how terminal size determination.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 57e3dc061b
irqtop: use util-linux libcommon facilities
Including NLS support.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:14 +00:00
Sami Kerola 4f6610f5ca
irqtop: make util-linux build-system to build the command
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:13 +00:00
Sami Kerola 952690cfd2
irctop: move source code to sys-utils/ directory
And remove files that util-linux does not need from the earlier repository.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-02-21 21:09:13 +00:00
zhenwei pi 2cd409cf71
irqtop: fix all warnings
use -Wall for compiling flags, and fix all warnings.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-02-21 21:09:13 +00:00
zhenwei pi 6ce4486272
irqtop: init README
add basic infomation in README

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-02-21 21:09:13 +00:00
zhenwei pi ae0dfe1412
irqtop: implement a new utility to display kernel interrupt
currently, there are usually 40/48/64/96 CPUs on a single server,
and a lot of interrupts are enabled by multi-queues of a NIC.
"/proc/interrupts" is not human readable any more.
'watch -d -n 1 "cat /proc/interrupts"' also can not work well.

so implement irqtop to show the interrupts information, we can
sort the interrupts by count(default), name and /proc/interrupts.

irqtop - IRQ : 49, TOTAL : 2361705032, CPU : 8, ACTIVE CPU : 8
 IRQ        COUNT   DESC
 CAL        21196   Function call interrupts
 LOC        13733   Local timer interrupts
 154         1430   IR-PCI-MSI 32768-edge      i915
 127         1322   IR-PCI-MSI 327680-edge      xhci_hcd
 RES         1224   Rescheduling interrupts
 146          336   IR-PCI-MSI 520192-edge      enp0s31f6
 IWI          135   IRQ work interrupts
 147           48   IR-PCI-MSI 31981569-edge      nvme0q2
 151           42   IR-PCI-MSI 31981573-edge      nvme0q6
 TLB            8   TLB shootdowns
 150            7   IR-PCI-MSI 31981572-edge      nvme0q5
 152            5   IR-PCI-MSI 31981574-edge      nvme0q7
 156            4   IR-PCI-MSI 1572864-edge      iwlwifi
 148            3   IR-PCI-MSI 31981570-edge      nvme0q3
 153            2   IR-PCI-MSI 31981575-edge      nvme0q8
 NMI            2   Non-maskable interrupts
 PMI            2   Performance monitoring interrupts
   0            0   IR-IO-APIC    2-edge      timer
   1            0   IR-IO-APIC    1-edge      i8042
   8            0   IR-IO-APIC    8-edge      rtc0
   9            0   IR-IO-APIC    9-fasteoi   acpi
  12            0   IR-IO-APIC   12-edge      i8042

test on 4.14 & 4.19, work fine. test on bare metal & kvm virtual
machine, work fine. hot-plug/hot-unplug virtual NIC during running
irqtop, work fine.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-02-21 21:09:13 +00:00