]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
5 years agoMerge branch 'topic/irq'
Karel Zak [Mon, 9 Mar 2020 09:25:48 +0000 (10:25 +0100)] 
Merge branch 'topic/irq'

5 years agodocs: fix spacing in irqtop and lsirq manual pages
Sami Kerola [Fri, 6 Mar 2020 20:34:06 +0000 (20:34 +0000)] 
docs: fix spacing in irqtop and lsirq manual pages

And convert font changing macros to ones used in howto-man-page.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agolsirq: mark --json and --pairs options mutually exclusive
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agobash-completion: update irqtop and lsirq completions
Sami Kerola [Fri, 6 Mar 2020 19:49:34 +0000 (19:49 +0000)] 
bash-completion: update irqtop and lsirq completions

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agolsirq: add -P option
Karel Zak [Fri, 6 Mar 2020 15:34:51 +0000 (16:34 +0100)] 
lsirq: add -P option

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsirq: add -n option
Karel Zak [Fri, 6 Mar 2020 15:26:06 +0000 (16:26 +0100)] 
lsirq: add -n option

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsirq: add new command
Karel Zak [Fri, 6 Mar 2020 15:21:10 +0000 (16:21 +0100)] 
lsirq: add new command

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: cleanup man page
Karel Zak [Fri, 6 Mar 2020 15:16:38 +0000 (16:16 +0100)] 
irqtop: cleanup man page

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: cleanup sort stuff
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()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: small cleanup in main()
Karel Zak [Fri, 6 Mar 2020 13:55:19 +0000 (14:55 +0100)] 
irqtop: small cleanup in main()

5 years agoirqtop: cleanup struct irq_stat use
Karel Zak [Fri, 6 Mar 2020 13:49:53 +0000 (14:49 +0100)] 
irqtop: cleanup struct irq_stat use

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: move WINDOW back to control struct
Karel Zak [Fri, 6 Mar 2020 13:21:46 +0000 (14:21 +0100)] 
irqtop: move WINDOW back to control struct

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: minor cleanup
Karel Zak [Fri, 6 Mar 2020 13:11:30 +0000 (14:11 +0100)] 
irqtop: minor cleanup

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: move independent code to irq-common.c
Karel Zak [Fri, 6 Mar 2020 13:04:33 +0000 (14:04 +0100)] 
irqtop: move independent code to irq-common.c

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: add struct irq_output
Karel Zak [Fri, 6 Mar 2020 12:38:02 +0000 (13:38 +0100)] 
irqtop: add struct irq_output

* add irq_output to keep top-like stufff independent on data
  management

* remove horrible "const"

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: keep table in functions only
Karel Zak [Fri, 6 Mar 2020 11:56:56 +0000 (12:56 +0100)] 
irqtop: keep table in functions only

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: remove dead code
Karel Zak [Fri, 6 Mar 2020 11:46:45 +0000 (12:46 +0100)] 
irqtop: remove dead code

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: separate normal and ncurses way
Karel Zak [Fri, 6 Mar 2020 11:44:16 +0000 (12:44 +0100)] 
irqtop: separate normal and ncurses way

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: remove unnecessary code
Karel Zak [Fri, 6 Mar 2020 11:36:41 +0000 (12:36 +0100)] 
irqtop: remove unnecessary code

* remove unused code smp_num_cpus
* care about hostname and timer only real top-like output

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: keep WINDOW pointer in functions only
Karel Zak [Fri, 6 Mar 2020 11:32:39 +0000 (12:32 +0100)] 
irqtop: keep WINDOW pointer in functions only

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: separate screen and scols code
Karel Zak [Fri, 6 Mar 2020 11:25:40 +0000 (12:25 +0100)] 
irqtop: separate screen and scols code

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: reorder function
Karel Zak [Fri, 6 Mar 2020 11:12:12 +0000 (12:12 +0100)] 
irqtop: reorder function

Move functions to make next changes more readable.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: cleanup command line options
Karel Zak [Fri, 6 Mar 2020 10:40:49 +0000 (11:40 +0100)] 
irqtop: cleanup command line options

* use -o for output columns (like we have in another tools)
* support -o +COLUMN

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: trim white spaces from end of name field
Sami Kerola [Wed, 4 Mar 2020 21:39:07 +0000 (21:39 +0000)] 
irqtop: trim white spaces from end of name field

Excess white spaces were easiest to see in json output.

    $ irqtop --once --json
    {
       "interrupts": [
          {"irq":"LOC", "total":7425148, "name":"Local timer interrupts "},
          {"irq":"51", "total":1848384, "name":"IR-PCI-MSI 32768-edge i915 "},
          {"irq":"RES", "total":1176665, "name":"Rescheduling interrupts "},
          ...

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: use -J for JSON
Karel Zak [Wed, 4 Mar 2020 13:58:18 +0000 (14:58 +0100)] 
irqtop: use -J for JSON

* add -J to the man page
* add note about default output
* be compatible with another util-linux tools and use -J

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: don't print header for --once
Karel Zak [Wed, 4 Mar 2020 13:51:12 +0000 (14:51 +0100)] 
irqtop: don't print header for --once

We don't use any extra header for lsblk, lsmem, ... so don't make it
different.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoirqtop: simplify terminal resizing
Karel Zak [Wed, 4 Mar 2020 13:47:20 +0000 (14:47 +0100)] 
irqtop: simplify terminal resizing

* don't care about term size and attrs when runs only once
* explicitly define signals
* resize immediately after SIGWINCH (to keep it nice for users)

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoiqrtop: cleanup header
Karel Zak [Wed, 4 Mar 2020 13:17:27 +0000 (14:17 +0100)] 
iqrtop: cleanup header

* add '|' to make it more readable
* use time string without 'T'

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agorev: report line on error
Karel Zak [Wed, 4 Mar 2020 12:20:56 +0000 (13:20 +0100)] 
rev: report line on error

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolscpu: use official name for HiSilicon tsv110
Karel Zak [Wed, 4 Mar 2020 11:54:24 +0000 (12:54 +0100)] 
lscpu: use official name for HiSilicon tsv110

Addresses: https://github.com/karelzak/util-linux/issues/969
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'topic/fdisk'
Karel Zak [Tue, 3 Mar 2020 15:22:10 +0000 (16:22 +0100)] 
Merge branch 'topic/fdisk'

5 years agofdisk: add support for parttype aliases
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>
5 years agosfdisk: extend --part-type, support aliases
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>
5 years agolibfdisk: add partition type aliases and shortcuts
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'.

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibmount: try read-only mount on write-protected superblock too
Karel Zak [Tue, 3 Mar 2020 10:39:10 +0000 (11:39 +0100)] 
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>
5 years agolibmount: move "already mounted" code to separate function
Karel Zak [Tue, 3 Mar 2020 09:55:28 +0000 (10:55 +0100)] 
libmount: move "already mounted" code to separate function

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agosfdisk: fix previous --append patch, improve man page
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>
5 years agosfdisk: fix --append to PT with gaps
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>
5 years agodocs: add note about AsciiDocs
Karel Zak [Thu, 27 Feb 2020 13:56:46 +0000 (14:56 +0100)] 
docs: add note about AsciiDocs

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibuuid: add uuid_parse_range() to man page and symbol-table
Karel Zak [Thu, 27 Feb 2020 13:52:06 +0000 (14:52 +0100)] 
libuuid: add uuid_parse_range() to man page and symbol-table

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'libuuid-range' of https://github.com/UQ-RCC/util-linux
Karel Zak [Thu, 27 Feb 2020 13:44:43 +0000 (14:44 +0100)] 
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()

5 years agosu, runuser: (man) add more info about PATH and PAM
Karel Zak [Thu, 27 Feb 2020 13:37:23 +0000 (14:37 +0100)] 
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>
5 years agohwclock: fix audit exit status
Karel Zak [Thu, 27 Feb 2020 13:04:55 +0000 (14:04 +0100)] 
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>
5 years agochsh: (man) fix default behavior description
Karel Zak [Thu, 27 Feb 2020 12:54:05 +0000 (13:54 +0100)] 
chsh: (man) fix default behavior description

Addresses: https://github.com/karelzak/util-linux/issues/967
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agofindmnt: make xalloc use mroe robust
Karel Zak [Thu, 27 Feb 2020 09:02:39 +0000 (10:02 +0100)] 
findmnt: make xalloc use mroe robust

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1807003
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolsblk: fix -P regression from v2.34
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>
5 years agolibfdisk: (gpt) partition name default to empty string
Karel Zak [Tue, 25 Feb 2020 11:39:26 +0000 (12:39 +0100)] 
libfdisk: (gpt) partition name default to empty string

Just for backward compatibility, otherwise it's strange ;-)

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: add missing comments
Karel Zak [Tue, 25 Feb 2020 11:25:17 +0000 (12:25 +0100)] 
libfdisk: add missing comments

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibfdisk: use ul_encode_to_utf8()
Karel Zak [Tue, 25 Feb 2020 11:21:32 +0000 (12:21 +0100)] 
libfdisk: use ul_encode_to_utf8()

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: fix compiler warning [-Wsign-compare]
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]

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agolibblkid: move UTF encoding function to lib/
Karel Zak [Tue, 25 Feb 2020 11:00:27 +0000 (12:00 +0100)] 
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>
5 years agolibuuid: add uuid_parse_range()
Zane van Iperen [Tue, 5 Nov 2019 07:21:17 +0000 (17:21 +1000)] 
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>
5 years agodocs: remove irqtop TODO item
Sami Kerola [Mon, 24 Feb 2020 18:27:16 +0000 (18:27 +0000)] 
docs: remove irqtop TODO item

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: tidy coding style and update usage() text
Sami Kerola [Mon, 24 Feb 2020 18:26:38 +0000 (18:26 +0000)] 
irqtop: tidy coding style and update usage() text

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agohwclock: make glibc 2.31 compatible
J William Piggott [Sat, 22 Feb 2020 01:03:47 +0000 (20:03 -0500)] 
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>
5 years agoumount: don't try it as non-suid if not found mountinfo entry
Karel Zak [Mon, 24 Feb 2020 12:02:09 +0000 (13:02 +0100)] 
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>
5 years agoirqtop: do not use fixed size /proc/interrupts line buffer
Sami Kerola [Sun, 23 Feb 2020 07:39:11 +0000 (07:39 +0000)] 
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>
5 years agoirqtop: add total and delta as own columns
Sami Kerola [Sat, 22 Feb 2020 16:42:56 +0000 (16:42 +0000)] 
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>
5 years agoirqtop: use name instead of desc as irq name field referal
Sami Kerola [Sat, 22 Feb 2020 15:19:09 +0000 (15:19 +0000)] 
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>
5 years agoirqtop: improve header
Sami Kerola [Sat, 22 Feb 2020 14:48:55 +0000 (14:48 +0000)] 
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>
5 years agoirqtop: hide cursor when in interactive mode
Sami Kerola [Sat, 22 Feb 2020 08:12:59 +0000 (08:12 +0000)] 
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>
5 years agoirqtop: display number of new interupts in-between updates
Sami Kerola [Fri, 21 Feb 2020 22:28:43 +0000 (22:28 +0000)] 
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>
5 years agoirqtop: add bash-completion
Sami Kerola [Sat, 8 Feb 2020 16:28:52 +0000 (16:28 +0000)] 
irqtop: add bash-completion

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: add manual page
Sami Kerola [Sat, 8 Feb 2020 16:03:07 +0000 (16:03 +0000)] 
irqtop: add manual page

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: use libsmartcols
Sami Kerola [Sat, 8 Feb 2020 16:00:20 +0000 (16:00 +0000)] 
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>
5 years agoirqtop: include hostname and timestamp to output header
Sami Kerola [Sun, 5 Jan 2020 10:40:12 +0000 (10:40 +0000)] 
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>
5 years agoirqtop: use epoll event loop
Sami Kerola [Sun, 5 Jan 2020 09:27:19 +0000 (09:27 +0000)] 
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>
5 years agoirqtop: move screen update to a separate function
Sami Kerola [Sun, 5 Jan 2020 09:00:28 +0000 (09:00 +0000)] 
irqtop: move screen update to a separate function

The main() was too long.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: fix open file descriptor leak
Sami Kerola [Sat, 4 Jan 2020 09:35:19 +0000 (09:35 +0000)] 
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>
5 years agoirqtop: change the update delay to use struct timeval
Sami Kerola [Sat, 4 Jan 2020 08:32:42 +0000 (08:32 +0000)] 
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>
5 years agoirqtop: use runtime control structure
Sami Kerola [Sat, 4 Jan 2020 08:08:17 +0000 (08:08 +0000)] 
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>
5 years agoirqtop: use lib/monotonic.c to determine uptime
Sami Kerola [Sat, 4 Jan 2020 07:45:43 +0000 (07:45 +0000)] 
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>
5 years agoirqtop: use memory allocation that check errors
Sami Kerola [Sat, 4 Jan 2020 07:40:49 +0000 (07:40 +0000)] 
irqtop: use memory allocation that check errors

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: avoid function like pre-processor definitions
Sami Kerola [Sat, 4 Jan 2020 07:33:01 +0000 (07:33 +0000)] 
irqtop: avoid function like pre-processor definitions

And simplify how terminal size determination.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: use util-linux libcommon facilities
Sami Kerola [Fri, 3 Jan 2020 21:06:43 +0000 (21:06 +0000)] 
irqtop: use util-linux libcommon facilities

Including NLS support.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirqtop: make util-linux build-system to build the command
Sami Kerola [Fri, 3 Jan 2020 20:38:38 +0000 (20:38 +0000)] 
irqtop: make util-linux build-system to build the command

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoirctop: move source code to sys-utils/ directory
Sami Kerola [Sat, 8 Feb 2020 17:07:18 +0000 (17:07 +0000)] 
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>
5 years agoirqtop: fix all warnings
zhenwei pi [Wed, 25 Dec 2019 09:56:07 +0000 (17:56 +0800)] 
irqtop: fix all warnings

use -Wall for compiling flags, and fix all warnings.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
5 years agoirqtop: init README
zhenwei pi [Mon, 11 Nov 2019 12:51:12 +0000 (20:51 +0800)] 
irqtop: init README

add basic infomation in README

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
5 years agoirqtop: implement a new utility to display kernel interrupt
zhenwei pi [Mon, 11 Nov 2019 12:48:59 +0000 (20:48 +0800)] 
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>
5 years agoMerge branch 'master' of https://github.com/benfrankel/util-linux
Karel Zak [Fri, 21 Feb 2020 08:29:48 +0000 (09:29 +0100)] 
Merge branch 'master' of https://github.com/benfrankel/util-linux

* 'master' of https://github.com/benfrankel/util-linux:
  docs: Improve grammar

5 years agodocs: Improve grammar
Ben Frankel [Fri, 21 Feb 2020 00:46:47 +0000 (16:46 -0800)] 
docs: Improve grammar

5 years agofdisk: update expected test outputs with command outputs
Sami Kerola [Thu, 20 Feb 2020 21:19:37 +0000 (21:19 +0000)] 
fdisk: update expected test outputs with command outputs

Reference; https://github.com/karelzak/util-linux/pull/959
Addresses: 5d271cefad0d7a5b4d2fb4fa0f26c1e341f1354c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agovarious: fix more lgtm scan warnings
Sami Kerola [Thu, 20 Feb 2020 20:08:00 +0000 (20:08 +0000)] 
various: fix more lgtm scan warnings

The logger and rtwake time function changes continue the same fixes as
previous commit - use thread safe functions.  The libsmartcols condition
removal is possible because width must be greater than tb->termwidth that is
size_t and cannot be smaller than zero.  And remove couple FIXME's that are
old and unlikely ever to get fixed.

Reference: 3160589d86470ce7d20c81090fb7f211b3822053
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agofdisk: improve list-types readability
Karel Zak [Thu, 20 Feb 2020 14:27:05 +0000 (15:27 +0100)] 
fdisk: improve list-types readability

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agosfdisk: (man) add note about type and shortcuts collision
Karel Zak [Thu, 20 Feb 2020 14:26:28 +0000 (15:26 +0100)] 
sfdisk: (man) add note about type and shortcuts collision

Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Tue, 18 Feb 2020 13:06:09 +0000 (14:06 +0100)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  exfat: Fix parsing exfat label

5 years agoMerge branch 'various-fixes' of https://github.com/kerolasa/util-linux
Karel Zak [Tue, 18 Feb 2020 13:02:41 +0000 (14:02 +0100)] 
Merge branch 'various-fixes' of https://github.com/kerolasa/util-linux

* 'various-fixes' of https://github.com/kerolasa/util-linux:
  kill: include sys/types.h before checking SYS_pidfd_send_signal
  libfdisk: fix pointer wraparound warning
  hwclock: update yacc file
  script: fix minor warning
  getopt: use examples installation directory in man page
  fstrim: randomize timer start time across 100 minutes
  various: use threadsafe versions of time functions [lgtm scan]
  write: fix potential string overflow

5 years agoMerge branch 'parttype-var' of https://github.com/nl6720/util-linux
Karel Zak [Tue, 18 Feb 2020 09:00:55 +0000 (10:00 +0100)] 
Merge branch 'parttype-var' of https://github.com/nl6720/util-linux

* 'parttype-var' of https://github.com/nl6720/util-linux:
  libfdisk: add Linux /var, /var/tmp and root verity GPT partition types

5 years agolscpu: fix SIGSEGV on archs without drawers & books
Karel Zak [Mon, 17 Feb 2020 12:13:11 +0000 (13:13 +0100)] 
lscpu: fix SIGSEGV on archs without drawers & books

The drawers and books are optional and not supported on all
architectures and in this case drawers/books relevant arrays are not
allocated, so don't access it although user wants it
(e.g.  "lscpu -p -y --output-all").

This patch also cleans up arrays allocation to make it more readable
and robust against edit mistakes.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1801760
Signed-off-by: Karel Zak <kzak@redhat.com>
5 years agokill: include sys/types.h before checking SYS_pidfd_send_signal
Sami Kerola [Sat, 15 Feb 2020 21:12:50 +0000 (21:12 +0000)] 
kill: include sys/types.h before checking SYS_pidfd_send_signal

Including sys/types.h must happen before SYS_pidfd_send_signal is checked,
because that header defines variable in normal conditions.  When sys/types.h
does not have SYS_pidfd_send_signal then fallback is defined in config.h
that is included by default, and has therefore worked fine before and after
this change.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agolibfdisk: fix pointer wraparound warning
Sami Kerola [Thu, 13 Feb 2020 21:28:37 +0000 (21:28 +0000)] 
libfdisk: fix pointer wraparound warning

libfdisk/src/gpt.c:1713:6: warning: assuming pointer wraparound does not
occur when comparing P +- C1 with P +- C2 [-Wstrict-overflow]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agohwclock: update yacc file
Sami Kerola [Thu, 13 Feb 2020 20:57:53 +0000 (20:57 +0000)] 
hwclock: update yacc file

$ bison --update sys-utils/hwclock-parse-date.y
sys-utils/hwclock-parse-date.y:287.1-12: warning: deprecated directive:
‘%pure-parser’, use ‘%define api.pure’ [-Wdeprecated]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoscript: fix minor warning
Sami Kerola [Thu, 13 Feb 2020 20:47:51 +0000 (20:47 +0000)] 
script: fix minor warning

ICO C does not allow extra ‘;’ outside of a function [-Wpedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agogetopt: use examples installation directory in man page
Sami Kerola [Wed, 12 Feb 2020 21:05:54 +0000 (21:05 +0000)] 
getopt: use examples installation directory in man page

Addresses: https://bugs.debian.org/913049
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agofstrim: randomize timer start time across 100 minutes
Sami Kerola [Wed, 12 Feb 2020 20:35:22 +0000 (20:35 +0000)] 
fstrim: randomize timer start time across 100 minutes

It should not matter when exactly fstrim runs, so spread these tasks across
time to help server farms and such to simultanously get busy with io.

Addresses: https://bugs.launchpad.net/bugs/1833593
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agovarious: use threadsafe versions of time functions [lgtm scan]
Sami Kerola [Sun, 9 Feb 2020 22:14:56 +0000 (22:14 +0000)] 
various: use threadsafe versions of time functions [lgtm scan]

Deprecating calls to not-thread safe asctime(), ctime(), and localtime()
calls is pretty close to pointless change.  Lets do it to reduce lgtm scan
warnings with justification it's nicer to use static analysis tools when
they have very few positives.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agowrite: fix potential string overflow
Sami Kerola [Sat, 8 Feb 2020 21:12:14 +0000 (21:12 +0000)] 
write: fix potential string overflow

Noticed when compiled with gcc verion 9.2.1 20200130.

term-utils/write.c:182:7: warning: ‘strcmp’ argument 1 declared attribute
  ‘nonstring’ [-Wstringop-overflow=]
  182 |   if (strcmp(u->ut_line, ctl->src_tty_name) == 0) {
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/utmpx.h:31,
                 from term-utils/write.c:60:
/usr/include/bits/utmpx.h:59:8: note: argument ‘ut_line’ declared here
   59 |   char ut_line[__UT_LINESIZE]
      |        ^~~~~~~

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
5 years agoexfat: Fix parsing exfat label
Pali Rohár [Wed, 12 Feb 2020 17:08:46 +0000 (18:08 +0100)] 
exfat: Fix parsing exfat label

According to released exfat specification, label is only 22 bytes long.

5 years agolibfdisk: add Linux /var, /var/tmp and root verity GPT partition types
nl6720 [Tue, 11 Feb 2020 10:04:02 +0000 (12:04 +0200)] 
libfdisk: add Linux /var, /var/tmp and root verity GPT partition types

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

Also replace a stray tab with a space.