Commit Graph

2867 Commits

Author SHA1 Message Date
Karel Zak 0b83e26373 lscpu: add info that caches sizes are sum
Addresses: https://github.com/karelzak/util-linux/issues/1258
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-08 11:25:15 +01:00
Karel Zak 81329c8d1c hwclock: use pointer to adjtime data
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-04 11:27:47 +01:00
Karel Zak 50cc633257 dmesg: fix and cleanup --read-clear
The function read_buffer() implements read and clear functionally, but
we do not differentiate between these actions in main() for error
messages, and one generic "dmesg: read kernel buffer failed" is used
in all cases. That's a bug.

This patch removes the "clear" action from read_buffer() and keeps it
for buffer reading only.  The "clear" action is implemented in main()
by separate klogctl(SYSLOG_ACTION_CLEAR) for cases. It means also for
"dmesg --read-clear"; we do not use SYSLOG_ACTION_READ_CLEAR anymore.

Now "clear+read" is:

 * syslog: SYSLOG_ACTION_READ_ALL + SYSLOG_ACTION_CLEAR
 * kmsg:   /dev/kmsg read()       + SYSLOG_ACTION_CLEAR

In old versions "dmesg --syslog --read-clear" (syalog backed) was
implemented by      logctl(SYSLOG_ACTION_READ_CLEAR) and it returns no
data for non-root  users (due to EPERM), "dmesg --read-clear" (kmsg)
returns data and EPERM for the "clear" action.

Now the command "dmesg --syslog --read-clear" and "dmesg --read-clear"
behaves in the same way -- returns data and EPERM for the "clear"
action.

Fixes: https://github.com/karelzak/util-linux/issues/1255
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-01 16:50:20 +01:00
Karel Zak 55d2dfa12c irqtop: check scols_line_set_data() return code
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-25 14:37:17 +01:00
Karel Zak 61074478fa irqtop: small cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-25 09:57:49 +01:00
Karel Zak a23aecc1bf irqtop: add per-cpu stats
irqtop | total: 1245107402 delta: 7394 | ws.net.home | 2021-02-24 20:11:09+01:00

        cpu0 cpu1 cpu2 cpu3 cpu4 cpu5 cpu6 cpu7
  %irq: 12.9 13.0 12.8 11.9 12.4 13.4 11.6 12.0
%delta: 13.7  9.7 22.6  7.9  9.5 17.5  8.3 10.8

       IRQ      TOTAL      DELTA NAME
       LOC  989162414       6111 Local timer interrupts
       TLB  100492740         67 TLB shootdowns
       CAL   95058001        321 Function call interrupts
        42   23893801        241 IR-PCI-MSI 1048576-edge nvidia
        30   20209392        494 IR-PCI-MSI 327680-edge xhci_hcd
       RES   12996335         86 Rescheduling interrupts
        29    1354219          4 IR-PCI-MSI 512000-edge ahci[0000:00:1f.2]
        41     682653         31 IR-PCI-MSI 409600-edge eno1
   ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-24 20:11:05 +01:00
Karel Zak 1b889dcc07 irqtop: print header in reverse mode
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-24 14:29:20 +01:00
Karel Zak 4f62b0b1dd readprofile: fix static analyzer warning [coverity scan]
Make sure we do not use step=0 and zero "fn_add - add0" as divisor.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-18 11:24:12 +01:00
Karel Zak 061e26d06d rfkill: fix static analyzer warning [coverity scan]
>>>     CID 365738:  Uninitialized variables  (UNINIT)
>>>     Using uninitialized value "ret". Field "ret" is uninitialized.
326             return ret;

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-18 11:09:31 +01:00
Thomas Deutschmann 037c7816ce
switch_root: check if mount point to move even exists
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
2021-02-08 15:35:07 +01:00
Karel Zak d687a6b4b0 eject: cleanup before successful exit
Fixes: https://github.com/karelzak/util-linux/issues/1239
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-02-01 12:21:18 +01:00
Karel Zak 31862cde0a fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-21 10:26:25 +01:00
Karel Zak c52d16098c ipcs: fallback for overflow
The previous commit 7a08784ab0 reduced
number of situation when we need fallback when kbytes calculated for
shmall pages, but there is still possible to see overflows.

This patch add fallback also for kbytes.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-18 16:04:18 +01:00
Vasilis Liaskovitis 7a08784ab0 ipcs: Avoid shmall overflows
Avoid computing the number of bytes in shmall, by only
computing and printing the number of Kbytes. This avoids
some overflows, e.g.

$ echo "4503599627370496" > /proc/sys/kernel/shmall
$ ipcs -l | grep 'max total shared memory'
Before:
max total shared memory (kbytes) = 18014398509481980
After:
max total shared memory (kbytes) = 18014398509481984

$ echo "99993599627370500" > /proc/sys/kernel/shmall
99993599627370500
$ ipcs -l | grep 'max total shared memory'
Before:
max total shared memory (kbytes) = 18014398509481980
After:
max total shared memory (kbytes) = 399974398509482000

v1->v2:
  Print the non-overflow KB value only for IPC_UNIT_KB and
IPC_UNIT_DEFAULT.
  This way --bytes and --human options will still get an expected
output
  (but not avoiding the overflow).

Signed-off-by: Vasilis Liaskovitis <vliaskovitis@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-18 11:38:58 +01:00
Karel Zak ca27216aa6 build-sys: remove fallback for security_context_t
It seems like overkill to provide this #ifdef. For example coreutils
use "char *" for all selinux contexts (since 2014).

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-13 13:12:19 +01:00
Karel Zak 183ad4a7b1 Revert "fallocate: (man) add hint about off/len limitations"
This reverts commit b2db5a71b5.

We already have this note in the man page. Don't duplicate it.
2021-01-06 12:05:50 +01:00
Karel Zak 4b447adf50 Merge branch '2020wk47' of https://github.com/kerolasa/util-linux
* '2020wk47' of https://github.com/kerolasa/util-linux:
  build-sys: sort various lists in configure.ac
  mkswap: tell how to fix insecure permissions and owner in warning
  lsipc: make default output byte sizes to be in human units
  man: add missing backslash to caret printing macro
  lscpu: fix variable shadowing
  uuidgen: give hint in usage() what uuid namepaces can be used
  uuidgen: use errx() rather than fprintf() when priting errors
  libuuid: simplify uuid_is_null() check
  uuidparse: use uuid type definitions from libuuid header
  uuidparse: use libuuid function to test nil uuid
2021-01-05 15:20:50 +01:00
Eric Biggers 432dfa0a20 sys-utils: mount.8: fix a typo
It should be "inode", not "i-node".

Signed-off-by: Eric Biggers <ebiggers@google.com>
2021-01-05 14:28:48 +01:00
Heinrich Schuchardt 7d15611779 fstab.5: NTFS and FAT volume IDs use upper case
The man-page indicates that mount expects UUIDs to be lower case.

Mention that NTFS and FAT volume IDs are to be specified in upper case.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2021-01-05 14:28:48 +01:00
Karel Zak 1b39cd7f63 Merge branch 'spelling' of https://github.com/scop/util-linux
* 'spelling' of https://github.com/scop/util-linux:
  *: spelling and grammar fixes
2021-01-04 13:42:08 +01:00
Karel Zak b2db5a71b5 fallocate: (man) add hint about off/len limitations
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-04 10:50:24 +01:00
Sami Kerola d0355b2e90
lsipc: make default output byte sizes to be in human units
Recent request to make ipcs(1) list sizes in human format caused the
observation lsipc(1) is not doing that either.  This commit changes sizes to
human format, assuming --bytes option is not used.

Reference: https://github.com/karelzak/util-linux/issues/1199
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-28 09:53:13 +00:00
Sami Kerola 01258182bb
lscpu: fix variable shadowing
sys-utils/lscpu-virt.c: In function ‘lscpu_read_virtualization’:
    sys-utils/lscpu-virt.c:574:9: warning: declaration of ‘buf’ shadows a previous local [-Wshadow]
      574 |    char buf[256];
          |         ^~~
    sys-utils/lscpu-virt.c:506:7: note: shadowed declaration is here
      506 |  char buf[BUFSIZ];
          |       ^~~

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-12-28 09:53:12 +00:00
Ville Skyttä 3c56068609 *: spelling and grammar fixes 2020-12-17 23:39:05 +02:00
Karel Zak 5ebff0918d lscpu: remove unnecessary prefix from static function
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-15 11:31:57 +01:00
Karel Zak cf8c191738 hwclock: fix compiler warnings [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c: In function 'synchronize_to_clock_tick_rtc':
sys-utils/hwclock.c:169:28: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:24: note: 'now.tv_usec' was declared here
sys-utils/hwclock.c:168:28: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:24: note: 'now.tv_sec' was declared here
sys-utils/hwclock.c:169:28: warning: 'begin.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:17: note: 'begin.tv_usec' was declared here
sys-utils/hwclock.c:168:28: warning: 'begin.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/hwclock-rtc.c:215:17: note: 'begin.tv_sec' was declared here

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-14 15:59:45 +01:00
Karel Zak 5d58258d62 blkdiscard: fix compiler warnings [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c: In function 'main':
sys-utils/blkdiscard.c:304:33: warning: 'now.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:17: note: 'now.tv_usec' was declared here
sys-utils/blkdiscard.c:305:37: warning: 'now.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:17: note: 'now.tv_sec' was declared here
sys-utils/blkdiscard.c:304:33: warning: 'last.tv_usec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:22: note: 'last.tv_usec' was declared here
sys-utils/blkdiscard.c:305:65: warning: 'last.tv_sec' may be used uninitialized in this function [-Wmaybe-uninitialized]
sys-utils/blkdiscard.c:152:22: note: 'last.tv_sec' was declared here

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-14 15:56:55 +01:00
Karel Zak eba9ef598f libmount: don't use deprecated security_context_t
libselinux >= 3.1 makes security_context_t type deprecated. Let's
ifdef it to avoid unwanted warnings.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-14 15:54:08 +01:00
Manuel Bentele cd3f22e6e0
losetup: fix wrong printf() format specifier for ino_t data type
Since the range of the ino_t data type is platform-specific (depending on
the wordsize), a usage of the fixed format specifier %PRIu64 is not correct
for ino_t on some 32-bit architectures, eg. ARM (Raspberry Pi 1). This issue
may lead to undefinied output and is not reported by gcc (in version 10.2.0
and 8.3.0-6+rpi1) even though -Wformat is enabled by -Wall. Therefore it is
most likely that it seems to be a false negative error in gcc's format
specifier check, so that this issue was never detected before.

This change fixes the issue by the use of a cast, since there is no
platform-independent format specifier for ino_t available. The wrong format
specifier %PRIu64 is replaced by %ju, where its corresponding variable of
type ino_t is casted to uintmax_t. The type uintmax_t represents the largest
platform-specific unsigned integer, so that all integer values are preserved
for a platform-independent printing.

Fixes: https://github.com/karelzak/util-linux/issues/1211
Signed-off-by: Manuel Bentele <development@manuel-bentele.de>
2020-12-05 23:51:27 +01:00
Karel Zak 58b510e580 libsmartcols: sanitize variable names on export output
The shells are very restrictive about variable names, only [:alnum:]
chars are allowed (and alphabetic chars as the first char).  The
library will replace "bad" chars with "_". The char '%' at the end is
replaced by _PCT.

Addresses: https://github.com/karelzak/util-linux/issues/1201
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-12-03 12:14:10 +01:00
Karel Zak 9b9954a9c4 Merge branch 'privfix' of https://github.com/ericonr/util-linux 2020-11-23 10:19:01 +01:00
Érico Rolim 93de9f687d setpriv: allow using [-+]all for capabilities.
The initial change to lib/caputils that allowed this was commit
5d95818757, which made it possible to
trust the value returned by cap_last_cap().

The error message was also somewhat misleading, since cap_last_cap()
being smaller than CAP_LAST_CAP happens when setpriv itself is built
with kernel headers older than the currently running kernel, not due to
libcap-ng.
2020-11-20 12:45:39 -03:00
Érico Rolim 0eba195d9e setpriv: small clean-up.
- Add _() calls for some strings which were missing it.
- In print_caps(), use the same error checking done in
  list_known_caps(); it is expected that libcap-ng will always return a
  string, even if it's only "cap_%d".
2020-11-20 12:33:23 -03:00
Karel Zak 57b74b0dcb Merge branch 'w45'
* w45:
  fdformat: remove command from default build
  more: improve error messaging when input file is directory
  ul: make set_column() zero check more obvious
  colrm: fix argument parsing
  rfkill: stop execution when rfkill device cannot be opened
  cifuzz: reindent yaml file
  man: make tilde and caret characters to render correctly
2020-11-20 12:01:22 +01:00
Masayoshi Mizuma f42f105b07 lscpu: show the number of physical socket on aarch64 machine without ACPI PPTT
Show the number of the number of physical socket even if the sysfs doesn't
have the physical socket information.

Note, lscpu shows the number of physical socket as 'Socket(s):' only if
root user runs it because accessing the DMI table requires root
privilege.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
2020-11-20 09:17:12 +01:00
Masayoshi Mizuma 788f90d69a lscpu: add helper to get physical sockets
Add a helper function, get_number_of_physical_sockets_from_dmi(),
to get physical sockets from DMI table in case of the sysfs for
cpu topology doesn't have the physical socket information.

get_number_of_physical_sockets_from_dmi() parse the DMI table
and counts the number of SMBIOS Processor Information (Type04)
structure.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
2020-11-20 09:17:12 +01:00
Masayoshi Mizuma 3cd676f5ec lscpu-dmi: Move some functions related to DMI to lscpu-dmi
Move some functions related to DMI to lscpu-dmi.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
2020-11-20 09:17:12 +01:00
Masayoshi Mizuma b04ab8dd8a lscpu-virt: split hypervisor_from_dmi_table()
Split hypervisor_from_dmi_table() to parsing dmi table and checking the
hypervisor vendor.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
2020-11-20 09:17:12 +01:00
Masayoshi Mizuma 73c0a766ff lscpu: use cluster on aarch64 machine which doesn't have ACPI PPTT
lscpu may show the wrong number of sockets if the machine is aarch64 and
doesn't have ACPI PPTT.

That's because lscpu shows the number of sockets by using a sysfs entry
(cpu/cpuX/topology/core_siblings). The sysfs entry is set by MPIDR_EL1
register if the machine doesn't have ACPI PPTT. MPIDR_EL1 doesn't show
the physical socket information directly. It shows the affinity level.

According to linux/arch/arm64/kernel/topology.c:store_cpu_topology(),
the top level of affinity is called as 'Cluster'.

Use Cluster instead of Socket on the machine which doesn't have ACPI PPTT.

This patch is useful for aarch64 machine which is based on ARM
SBBR v1.0 and v1.1, the specs don't require ACPI PPTT. ARM SBBR v1.2
requires ACPI PPTT.

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
2020-11-20 09:17:12 +01:00
Karel Zak 1c675ebee0 lscpu: fix resource leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-19 12:00:58 +01:00
Karel Zak b9b28b641e lscpu: fix possible null dereferences [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-19 11:57:36 +01:00
Karel Zak 77a3708489 umount: ignore --no-canonicalize,-c for non-root users
It seems better to ignore this option than drop-permissions and later
exit with EPERMs. This change makes umount(8) more compatible with
fuser user umounts by systemd where -c is used to reduce overhead etc.

Addresses: https://github.com/karelzak/util-linux/issues/1192
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-19 11:12:06 +01:00
Pino Toscano 367972fae1 hwclock: do not assume __NR_settimeofday_time32
Check that __NR_settimeofday_time32 exists before trying to use it as
syscall number.

Signed-off-by: Pino Toscano <toscano.pino@tiscali.it>
2020-11-17 11:32:45 +01:00
Érico Rolim b3ea5aaa64 lscpu-virt: fix return type of read_hypervisor_cpuid for non x86. 2020-11-15 11:53:39 -03:00
Sami Kerola 06229abccf
rfkill: stop execution when rfkill device cannot be opened
Without this two error messages are printed when rfkill device
cannot be opened.

    $ rfkill
    rfkill: cannot open /dev/rfkill: No such file or directory
    rfkill: cannot read /dev/rfkill: Bad file descriptor

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-14 15:22:34 +00:00
Sami Kerola 3ea54b843c
man: make tilde and caret characters to render correctly
As mentioned in 'Generating optimal glyphs' title in the manual page
mentioned in reference:

    Where a proper caret (^) that renders well in both a terminal and PDF is
    required, use "\(ha".

    Using a naked "~" character results in a poor rendering in PDF.  Instead
    use "\(ti".

Reference: https://man7.org/linux/man-pages/man7/man-pages.7.html#STYLE_GUIDE
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-14 15:22:34 +00:00
Karel Zak d4cb6a0335 lscpu: fix memory leaks
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 10:20:33 +01:00
Masayoshi Mizuma 8014104bea lscpu-arm: Add "BIOS Vendor ID" and "BIOS Model name" to show the SMBIOS information.
After commit: 367c85c47 ("lscpu: use SMBIOS tables on ARM for lscpu"),
Model name for A64FX shows like as:

   Model name:       461F0010

That's because 367c85c47 changes to get the modelname from Processor
Version of SMBIOS.

To fix that, use the hard corded table to show the "Model name" and
add two new lines; "BIOS Vendor ID" and "BIOS Model name" to show the
SMBIOS information.

lscpu shows the SMBIOS information when root user runs it because
accessing the SMBIOS information requires root privilege.

[kzak@redhat.com: - port the patch to new lscpu code]

Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 10:06:26 +01:00
Jeremy Linton dbc2772305 lscpu: Even more Arm part numbers
Over the past two years Arm has published further MIDR/part numbers
on https://developer.arm.com/ip-products/processors/cortex-a.

Lets sync the arm_part structure for A65, A76AE, A77 and A78*.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
2020-11-13 09:33:32 +01:00
Karel Zak 76b6666c0e lscpu: (arm) reuse parsed vendor ID
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 10b71aede2 lscpu: remove unused code
lscpu-dmi.c is no more used by new lscpu code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 60e7ccb8e8 lscpu: Adapt MIPS cpuinfo
Port commit

  commit 6cb8af7be2
  Author: Jiaxun Yang <jiaxun.yang@flygoat.com>
  Date:   Sat Mar 28 12:19:42 2020 +0800

to new lscpu code.

References: 6cb8af7be2
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak ddc92e3993 lscpu: add shared cached info for s390 lscpu -C
Port commit
 commit 318542e060
 Author: Sumanth Korikkar <sumanthk@linux.ibm.com>
 Date:   Fri Jun 5 18:15:10 2020 +0200

to new lscpu code.

References: 318542e060
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Thomas Abraham 80fcd2c802 lscpu: avoid segfault on PowerPC systems with valid hardware configurations
ntypes greater than 1 is valid in some hardware configurations, and an assert()
on the value isn't necessary or very future proof

[kzak@redhat.com: - port this patch to new code]

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 05b9c556f6 lscpu: fix MHZ parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak cc94324ebd lscpu: improve bogomips use
* keep global (cputype) bogomips
* add per-CPU bogomips
* use bogomips from the first CPU as global (for cputype) if /proc/cpuinfo does not provide global bogomips
* add BOGOMIPS column for to -e/-p output

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6321d34f0f lscpu: add note about cache IDs
We read the ID from /sys/devices/system/cpu/cpu*/cache/index*/id.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6d880d3d46 lscpu: add MHZ column
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 7155a57d34 lscpu: don't use section for extra caches
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak d4228e9de2 lscpu: fix for sparc64
We do not read CPUs from cpuinfo on sparc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 19ddc05e11 lscpu: improve topology calculation
Let's make it more robust and readable. The sysinfo file on s390 may
contain zeros, so we need to check the values and fallback to data
from shared maps if necessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6648a70eb2 lscpu: assume gaps in list of CPUs
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak e07cca6b85 lscpu: fix last caches separator in -e and -p output
Note that cxt->ncaches is number of all instances, but we split
output according to split output according to caches names.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak ada1a387b1 lscpu: generate cache ID if not available
The file /sys/devices/system/cpu/cpu*/cache/index*/id is not available
in old kernels. This patch add code to generate IDs according to cache
type and level.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 0710bb133f lscpu: cleanup --parse
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 63c5e7f801 lscpu: cleanup -e
* keep one sharedmap per cache instance
* initialize topology IDs to -1
* rewrite -e code to use a new data structs

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9d480e578a lscpu: add extra caches to --cache output
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 1766641a1b lscpu: cleanup --cache
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 91eef60ca3 lscpu: split output to sections
Let's make it more readable for humans.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak e3f213184a lscpu: add sections
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 01bea871dd lscpu: add rest of summary
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 778254d9a2 lscpu: keep static/dynamic MHz in cputype struct
The Dynamic and Static MHz are /proc/cpuinfo s390 per-CPU fields, but
we display it as a single value according the first parsed CPU. For
this purpose we store the values from the first CPU in lscpu_cputype.

For -p and -e outputs we will print per CPU values.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 93a1bb1009 lscpu: add another part of summary output
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6d5699e6b5 lscpu: add functions to get CPU freq
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 406b088cb4 lscpu: fix NUMAs reading code
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 2f5e2730fe lscpu: add per type summary function
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak db919abc13 lscpu: use size_t for counters
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak d8813bb378 lscpu: print generic part of the summary
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak eaf32c65be lscpu: add setsize to lscpu context
Don't recalculate again and again setsize from maxcpus.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 05abf5944e lscpu: add function to count caches size
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6fbb53286d lscpu: use cache ID, keep caches independent on CPU type
The cache is identified by Type, Level and ID, the ID is unique cache
instance identifier (of the type).

This changes forces lscpu allocate more lscpu_cache instances (than
old version), but now we're ready for arbitrary scenario where
different CPU types share caches and the same cache type uses
different size in different instances, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 4b9cbc38a4 lscpu: use new code to read CPUs info
and remove test program from lscpu-cputype.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak b73d38b1d1 lscpu: convert getopt block to new API
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 30b912d335 lscpu: add LSCPU_OUTPUT_ enum
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 27c349f9d1 lscpu: move to main function to init context
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 43715b4ea8 lscpu: move debug initialization to main
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 095be2c20e lscpu: merge new API to lscpu.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 7454b598e4 lscpu: use constants from new API
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak f9ac021032 lscpu: remove obsolete code
This is the first step in conversion from old lscpu to the new code.
The patch removes obsolete code from lscpu.c and lscpu.h. The old
output code in lscpu.c is temporary disabled by #ifdef due to
incompatibility between old and new internal APIs -- this will be
changed later by small steps to make all all the changes review-able.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 3d590f8ea1 lscpu: (virt) add macros for VMWARE
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak eadaf6d758 lscpu: (topology) read caches from /sys
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak e36e01f980 lscpu: sort extra caches
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak ff7449d2ea lscpu: improve debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak ffb7fcfbba lscpu: remove unused function
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 25c2a72cd6 lscpu; (cpuinfo) parse caches
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9d08a19d54 lscpu: (topology) add read_mhz()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 8c587fad9f lscpu: (topology) add read_configure()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6d1a2705f7 lscpu: (topology) add read_address()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 2075eb60b5 lscpu: hide all to lscpu_read_topology()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9aa82cd7e6 lscpu: (virt) simplify hypervisor parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak ee0fabda30 lscpu: (cpuinfo) rewrite parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak f495abb799 lscpu: (cpuinfo) fill empty cputype
Don't introduce a new CPU-type if the current is empty.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak f5d1353246 lscpu: new cpuinfo parser
* extendable by new patterns
* simple semantic
* the same code for all pattern types

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 021d0b3d1d lscpu: keep hypervisor name in allocated memory
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 801b125f8f lscpu: temporary commit
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 6baa4df7ec lscpu: improve topology calculation, use /proc/sysinfo
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak fd5999d9ac lscpu: support s390 cpuinfo processor-pre-line format
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak fd35a1dae6 lsblk: add lscpu_read_topology_polarization()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak f669523ba0 lscpu: move topology stuff to separate file
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 0266f5cbab lscpu: improve topology debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak fa6a21bf63 lscpu: calculate threads number from type specific values
Don't use global CPU masks (like "online" or "present") to
calculate type specific number of threads due systems with
mixed CPU types.

It's also necessary to check all thread_siblings maps to get the
highest number, because some threads (CPUs) may be disables, for
example old lscpu calculates number of threads from the cpu0 and
if you disable cpu0's sibling (cpu4):

	CPU(s):                          8
	On-line CPU(s) list:             0-7
	Thread(s) per core:              2        <---
	Core(s) per socket:              4
	Socket(s):                       1

 # chcpu --disable 4
 CPU 4 disabled

	CPU(s):                          8
	On-line CPU(s) list:             0-3,5-7
	Off-line CPU(s) list:            4
	Thread(s) per core:              1        <--- !
	Core(s) per socket:              4
	Socket(s):                       1

because 'thread_siblings' contains only one thread for cpu0:

 # cat /sys/devices/system/cpu/cpu{0,1,2,3,4,5,6,7}/topology/thread_siblings_list
 0
 1,5
 2,6
 3,7
 cat: /sys/devices/system/cpu/cpu4/topology/thread_siblings_list: No such file or directory
 1,5
 2,6
 3,7

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak b8a319460d lscpu: deallocate maps
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 314aa95fd5 lscpu: add lscpu_read_topolgy_ids()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9d5f3b4873 lscpu: add lscpu_read_topology()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 9c5b106b01 lscpu: add lscpu_cpus_loopup_by_type(), improve readability
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 504de58512 lscpu: convert ARM decoding to new API
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak a94bb4357e lscpu: cleaup arch freeing
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 909d35758e lscpu: add lscpu_read_virtualization()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 154ee5a992 lscpu: add lscpu_read_numas()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 617d8fbec5 lscpu: fix mem-leak in cpu
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 0796923aa8 lscpu: add lscpu_read_vulnerabilities()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak b152ec5436 lscpu: cleanup lscpu_unref_cputype()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 5a6da72c42 lscpu: add lscpu_read_extra()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 551f2b4dc9 lscpu: add lscpu_read_cpulists()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak d34b7f1b82 lscpu: add lscpu_read_architecture()
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak d234a38101 lscpu: (cputype) simplify cpuinfo parsing
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 855bab2a2e lscpu: add lscpu_cpu to internal API
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 7079f4662c lscpu: (cputype) move temporary stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak cbf8f1297b lscpu: (cputype) add header file, cleanup patterns code
* move structs definitions to header file
* define set of /proc/cpuinfo parsing patterns for cpu-type and for
  CPUs

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 329ec35ff0 lscpu: (cputype) add cpuinfo parser
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 71464ded30 lscpu: (cputype) add ref-counting, allocate context
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 450cb0b724 lscpu: (cputype) add debug stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak 405d51edf4 lscpu: add very basic cputype code
The current lscpu assumes that all CPUs in the system are the same.
Unfortunately this is not true. We need to split all internal CPUs
descriptions to CPU-type and CPU.

This patch add lscpu-cputype.c where will be CPU-type description --
mostly based on /proc/cpuinfo.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-13 09:19:02 +01:00
Karel Zak e5781b3d3b flock: keep -E exit status more restrictive
Addresses: https://github.com/karelzak/util-linux/issues/1180
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-11-09 10:53:23 +01:00
Karel Zak 1d6e1b62e5 Merge branch 'execl-null' of https://github.com/DankRank/util-linux
* 'execl-null' of https://github.com/DankRank/util-linux:
  cast NULL to char * when using execl
2020-11-03 12:40:35 +01:00
Sami Kerola 364de8f4f5 lib/randutils: rename random_get_bytes()
Rename random_get_bytes() to avoid colliding a Solaris library function that
has the same name.

Reported-by: Sad Clouds <cryintothebluesky@gmail.com>
Reference: https://lore.kernel.org/util-linux/20201101141608.ba365cf67d92ee3973226de9@gmail.com/
Reference: https://blogs.oracle.com/solaris/solaris-random-number-generation-v2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-11-03 12:38:45 +01:00
Egor Chelak 1b10fa0ef7 cast NULL to char * when using execl
When calling variadic functions, NULL must be explicitly cast to a
desired type.
This is noted in the exec(3) manpage.

The call in newgrp.c was changed for consistency.

Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
2020-10-29 19:49:07 +02:00
Karel Zak 732d75945e dmesg: add --since and --until
$ date
Wed 21 Oct 2020 12:05:07 PM CEST

$ dmesg --ctime --since '1 hour ago'
[Wed Oct 21 11:47:13 2020] AAA
[Wed Oct 21 11:55:48 2020] BBB

$ dmesg --ctime --since '1 hour ago' --until '10 minutes ago'
[Wed Oct 21 11:47:13 2020] AAA

Addresses: https://github.com/karelzak/util-linux/issues/1166
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-21 12:09:18 +02:00
Karel Zak d3e58a8ec9 switch_root: fix double close [coverity scan]
Up on successful fdopendir(3) file descriptior that will be closed, that
happens in recursiveRemove() switch_root(8) function.

CID: 360697
Reference: https://pubs.opengroup.org/onlinepubs/9699919799/functions/fdopendir.html
Co-Author: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-16 11:56:35 +02:00
Sami Kerola 12558a4c47 nsenter / switch_root: fix insecure chroot [coverity scan]
If a call to chroot is not followed by a call to chdir("/") the chroot jail
confinement can be violated.  See also CWE-243.

CID: 360718
CID: 360800
Reference: http://cwe.mitre.org/data/definitions/243.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2020-10-16 11:32:38 +02:00
Sami Kerola 232fcae81c unshare: fix bad bit shift operation [coverity scan]
Variable cap was 32 bits and shifting it by 64 bits resulted to the shift
going over a variable boundary.

CID: 360799
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-16 11:27:42 +02:00
Karel Zak f51c63af47 Merge branch 'dusty-remove-fstab-condition' of https://github.com/dustymabe/util-linux
* 'dusty-remove-fstab-condition' of https://github.com/dustymabe/util-linux:
  fstrim: remove fstab condition from fstrim.timer
2020-10-14 10:23:20 +02:00
Dusty Mabe 9651b677f1
fstrim: remove fstab condition from fstrim.timer
In 9995da0 we added support to fstrim to be able to fall back to
`/proc/self/mountinfo` if `/etc/fstab` didn't exist, but we forgot
to remove the `/etc/fstab` condition from the timer. Let's remove
that condition from the timer so we can go back to periodically
running `fstrim.service`.
2020-10-13 11:28:07 -04:00
Karel Zak 75cd5e2f28 losetup: increase limit of setup attempts
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-13 12:55:44 +02:00
Karel Zak 3ff6fb802d losetup: avoid infinite busy loop
issue report:
 if i run the heavy duty test from #16859 a couple of times I can get
 the loopback layer in the kernel into a state where there's a loopback
 block device allocated, that you can open, but where both LOOP_CLR_FD
 and _SET_FD fail with EBUSY. and /dev/loop-control still returns it as
 the next free one...  weird state util-linux losetup when called to
 allocate a new device then freezes

This commit:
* restrict number of attempts to 16
* use 200000ms sleep between attempts
* add note about non-atomic loop device setup to the man page

Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-13 10:58:04 +02:00
Karel Zak eee886ba1d build-sys: exclude GPL from libcommon
The library is not distributed and almost all code in this ar(1)
archive is Public Domain or LGPL ... but let's avoid any doubts and do
not mix non-GPL and GPL code there.

Addresses: https://github.com/karelzak/util-linux/issues/1157
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-06 13:26:36 +02:00
Karel Zak 558880dd35 Merge branch 'frkaya/loopconfig' of https://github.com/franksinankaya/util-linux
* 'frkaya/loopconfig' of https://github.com/franksinankaya/util-linux:
  loopdev: use LOOP_CONFIG ioctl
2020-10-05 14:51:45 +02:00
Karel Zak 3cb827ad36 hwclock: make tz use more robust [coverity scan]
It's probably unnecessary, but let's make it more robust and keep
static analyzers happy.

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-10-01 13:44:44 +02:00
Sinan Kaya d5fd456c88 loopdev: use LOOP_CONFIG ioctl
Prefer to use the new LOOP_CONFIG ioctl.
https://lwn.net/Articles/820408/

Signed-off-by: Sinan Kaya <sinan.kaya@microsoft.com>
2020-09-30 20:04:21 -04:00
Karel Zak b76b4788be lscpu: don't use smbios when read snapshots
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-30 14:57:08 +02:00
Jeffrey Bastian 367c85c472 lscpu: use SMBIOS tables on ARM for lscpu
ARM SBBR (Sever Base Boot Requirements) require SMBIOS tables, and
SMBIOS Type 4 describes the CPU manufacturer and model name (among other
details).  If SMBIOS Type 4 is present, use it to extract these strings.

Example output (before and after the patch) on an HP m400, Lenovo HR330A,
and HPE Apollo 70:

[root@hp-m400 ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           APM
Model:               1
Model name:          X-Gene
Stepping:            0x0
[root@hp-m400 ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       AppliedMicro
Model:                           1
Model name:                      X-Gene
Stepping:                        0x0

[root@lenovo-hr330a ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           APM
Model:               2
Model name:          X-Gene
Stepping:            0x3
[root@lenovo-hr330a ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       Ampere(TM)
Model:                           2
Model name:                      eMAG
Stepping:                        0x3

[root@hpe-apollo-70 ~]# /usr/bin/lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:           Cavium
Model:               1
Model name:          ThunderX2 99xx
Stepping:            0x1
[root@hpe-apollo-70 ~]# ./lscpu | grep -i -e vendor -e model -e stepping
Vendor ID:                       Cavium Inc.
Model:                           1
Model name:                      Cavium ThunderX2(R) CPU CN9980 v2.1 @ 2.20GHz
Stepping:                        0x1

[kzak@redhat.com: - move dmi_header to lscpu.h
                  - make arm_cpu_smbios() more robust for failed
		    open() and read()
                  - use original arm_cpu_decode() also on failed
		    arm_cpu_smbios()]

Signed-off-by: Jeffrey Bastian <jbastian@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-09-29 13:28:16 +02:00
Shunsuke Nakamura a625b32e2c lscpu: Add FUJITSU aarch64 A64FX cpupart
Add an entry for FUJITSU aarch64 part A64FX.
I tested it on the FX1000.

Signed-off-by: Shunsuke Nakamura <nakamura.shun@fujitsu.com>
2020-09-29 12:42:44 +02:00
Thomas Abraham cbe3304bc4 lscpu: avoid segfault on PowerPC systems with valid hardware configurations
ntypes greater than 1 is valid in some hardware configurations, and an assert()
on the value isn't necessary or very future proof
2020-09-24 14:52:33 -04: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
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
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 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 087203733d
him -> them 2020-08-28 19:17:00 +02:00
leeceeksdee 3a03903011
him -> them 2020-08-28 19:16:33 +02:00
leeceeksdee d15a6c22cf
he -> they 2020-08-28 19:12:44 +02:00
Karel Zak f1f48270c9 mount, umount: restore environ[] after suid drop
The commands mount and umount sanitize environment variables as it
works with suid permissions by default. Since v2.36 it's possible
that the commands drop the permissions and continue as regular user.
It seems we also need to restore the original environ to keep things
consistent for users (e.g. HOME=).

The implementation is pretty simple -- it keeps in memory removed
variables and use it after switch to non-suid mode.

Addresses: https://github.com/karelzak/util-linux/issues/880
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-25 10:48:29 +02:00
Karel Zak 69e4fbfbfd hwclock: add fallback if SYS_settimeofday does not exist
It seems Musl-C removes SYS_settimeofday macro at all.

Addresses: 9c6139a720 (commitcomment-41290951)
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-08-11 11:02:31 +02:00
Michael Kerrisk (man-pages) 04be4affb7 Manual pages: wdctl.8: typo fix 2020-07-24 14:41:49 +02:00
Chris Hofstaedtler 7259f318b9 manpages: fix "The example command" in AVAILABILITY section
Signed-off-by: Chris Hofstaedtler <zeha@debian.org>
2020-07-24 09:09:43 +02:00
zhenwei pi 635ac7dad8 irqtop/lsirq: add softirq for man page
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-07-23 12:23:56 +02:00
zhenwei pi b2a49bc243 irqtop/lsirq: add additional desc for softirq
Suggested by Karel, add additional description to make softirq more
friendly to end-user. Discuss about this:
    https://github.com/karelzak/util-linux/pull/1079

Note that, we should keep softirqs table align to kernel source code.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-07-23 12:23:56 +02:00
zhenwei pi b6ce063b04 irqtop/lsirq: support softirq
Add '-S' or '--softirq' for irqtop/lsirq, instead of interrupts, show
softirqs infomation. Because there is no more description of softirq,
do not show 'NAME' column by default.

Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
2020-07-23 12:23:56 +02:00
Shin'ichiro Kawasaki e5ad3a6ad0 blkzone: add capacity field to zone report
NVMe ZNS specification defines zone capacity. The report zone interface
of Linux kernel supports it. Expose it in report zone by blkzone command.

Signed-off-by: Hans Holmberg <hans.holmberg@wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
2020-07-23 12:23:56 +02:00
Karel Zak 29e204d117 docs: reword others "allow to"
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-14 14:31:29 +02:00
Michael Kerrisk (man-pages) 4f68c8b179 Manual pages: various: reword "allow(s) to"
The wording "allow(s) to" is not grammatical English. Reword various
pages to use a more correct form such "can be use to" or "allows
the [noun] of".

Aklong the way, fix a few nearby wording errors in some pages.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 14:08:54 +02:00
Michael Kerrisk (man-pages) c0de507ae5 manual pages: adjtime_config.5: format pathname with .I
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-07-14 13:58:59 +02:00
Bjarni Ingi Gislason db850f3c19 Subject: docs: remove unnecessary paragraph macros
Remove a second paragraph macro (.TP, .PP) as it does not change the
output (.SS/.PP) or it adds an extra empty line (.TP/.TP)

  Warning from "mandoc -Tlint":

mandoc: ./sys-utils/hwclock.8.in:299:2: WARNING: line scope broken: TP breaks TP
mandoc: ./sys-utils/hwclock.8.in:459:2: WARNING: skipping paragraph macro: PP after SS
mandoc: ./sys-utils/hwclock.8.in:543:2: WARNING: skipping paragraph macro: PP after SS
mandoc: ./sys-utils/hwclock.8.in:574:2: WARNING: skipping paragraph macro: PP after SS
mandoc: ./sys-utils/hwclock.8.in:673:2: WARNING: skipping paragraph macro: PP after SS
mandoc: ./sys-utils/hwclock.8.in:721:2: WARNING: skipping paragraph macro: PP after SS

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-07-14 10:37:49 +02:00
Yuri Chornoivan aa1c7a7686 More typo fixes by fossies 2020-07-13 15:33:42 +03:00
Yuri Chornoivan 311e33afef Fix minor typos 2020-07-09 20:14:32 +03:00
Karel Zak c9cad81a0c Merge branch 'cryptsetup_dlopen' of https://github.com/bluca/util-linux
* 'cryptsetup_dlopen' of https://github.com/bluca/util-linux:
  cryptsetup: add option to use via dlopen in libmount
2020-07-08 09:55:12 +02:00
Karel Zak c02980d6f2 lsmem: report inaccessible /sys/devices/system/memory
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1794160
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-08 08:51:45 +02:00
Karel Zak bf1d0a4ea0 lsmem: make it without leaks for non-error output
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-08 08:48:45 +02:00
Luca Boccassi 488fd4c3df cryptsetup: add option to use via dlopen in libmount
Enabling libcrypsetup in libmount had several unintended side
effects.
First of all, it increases the Debian minimal image size by
~2.5% (5.6MB worth of new libraries).
Then, due to libcryptsetup linkage to OpenSSL and libjson-c,
it causes incompatibilities with external programs linking
against both libmount and a private, static, old version of
OpenSSL, or external programs linking against libjansson or
json-glib, which have one symbol in common with libjson-c.

If ./configure is ran with --with-crypsetup=dlopen,
instead of linking to libcrypsetup, use dlopen to resolve
the symbols at runtime only when the verity feature is
used, thus avoiding clashes and keeping images size down.

Fixes #1081

Signed-off-by: Luca Boccassi <luca.boccassi@microsoft.com>
2020-07-07 16:43:55 +01:00
Karel Zak 2e5819df6c unshare: (man) add note about signals on --fork
Addresses: https://github.com/karelzak/util-linux/pull/1087
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-03 13:03:58 +02:00
Karel Zak 9120e39f92 Merge branch 'unshare-signals' of https://github.com/DaanDeMeyer/util-linux 2020-07-03 12:56:54 +02:00
Daan De Meyer 3ba6736f3a unshare --fork: Ignore SIGINT and SIGTERM in parent 2020-07-02 16:35:21 +02:00
Evgeny Vereshchagin ad6aef0ea8 revert a680b2abe7
It's not clear what that commit was supposed to fix. Looks like
772420322d should have helped there.
2020-07-02 10:23:47 +00:00
Evgeny Vereshchagin 7b81644f10 travis: turn on -Werror 2020-07-02 09:49:12 +00:00
Bjarni Ingi Gislason 67fcb85739 sys-utils: mount.8: split a long line into two
Split two long lines, adding '\e' at the end of the first part,
as otherwise the last part of them disappears at the right margin in
the printed output (pdf).

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-06-24 15:42:43 +02:00
Karel Zak 965334990e Merge branch 'some/small/fixes' of https://github.com/lnslbrty/util-linux
* 'some/small/fixes' of https://github.com/lnslbrty/util-linux:
  login: fixed invalid sizeof usage
  libfdisk, unshare: fix gcc-4.9.4 warnings
2020-06-24 15:32:54 +02:00
Alexey Gladkov 9fd01b10d0 setarch: add arm and aarch64 architectures to transition rules
Since aarch64 kernel can be configured with compat 32-bit support
enabled, extend translation rules in a way similar to x86/x86_64.

Suggested-by: "Dmitry V. Levin" <ldv@altlinux.org>
Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
2020-06-24 15:05:53 +02:00
Alexey Gladkov 7f48cfb0e4 setarch: make verify_arch_domain extendable
When other compatible architectures are introduced, they will also have
to be added to the verifier.

Signed-off-by: Alexey Gladkov <gladkov.alexey@gmail.com>
2020-06-24 15:05:53 +02:00
Toni Uhlig 9eba847689
libfdisk, unshare: fix gcc-4.9.4 warnings
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
2020-06-19 20:37:33 +02:00
Karel Zak 883d1d6564 build-sys: fix blkdiscard blkid.h use
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-19 19:04:10 +02:00
Rupesh Girase 4bee67e2d1 Manual pages: losetup.8: Fix "--direct-io" defaults
"--direct-io" option is "off" by default while configuring
loop device but it's mentioned "on" in man page.

Signed-off-by: Rupesh Girase <rgirase@redhat.com>
2020-06-19 10:03:00 +02:00
Lukas Czerner 0f23e4c13e blkdiscard: Refuse to proceed if signatures are found
Currently the blkdiscard has the ability to wipe out entere device in a
matter of seconds. This is fine as long as it's intentional, it is
potentially catastrophic if it's not.

With this commit blkdiscard will check for existing signatures on the
device and refuse to continue if any are found unless the operation is
forced with the -f option.

In an attempt to avoid breaking existing automation scripts the force is
only required when stdin refers to a terminal.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
2020-06-19 10:03:00 +02:00
Jakub Wilk 8f3ce436b8 unshare: fix man page formatting
Signed-off-by: Jakub Wilk <jwilk@jwilk.net>
2020-06-16 20:11:38 +02:00
Michael Kerrisk (man-pages) d651a1baa9 Manual pages: setpriv.1: warn users of restrictions on capability changes
The kernel imposes various restrictions on the changes that can be
made to the inheritable, ambient, and bounding sets. Warn the user
about that.

Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-06-15 11:34:58 +02:00
Michael Kerrisk (man-pages) e350b5b3b6 Manual pages: setpriv.1: Various minor wording and formatting fixes
Signed-off-by: Michael Kerrisk (man-pages) <mtk.manpages@gmail.com>
2020-06-15 11:34:58 +02:00
Bjarni Ingi Gislason ba6b6d8d08 doc: sys-utils/*: fix some warnings from "mandoc -T lint"
mandoc: ./sys-utils/adjtime_config.5:26:1: WARNING: skipping paragraph macro: sp after PP

mandoc: ./sys-utils/chcpu.8:98:2: WARNING: skipping paragraph macro: br at the end of SH

mandoc: ./sys-utils/choom.1:26:22: STYLE: unterminated quoted argument

mandoc: ./sys-utils/dmesg.1:90:5: STYLE: unterminated quoted argument
mandoc: ./sys-utils/dmesg.1:147:5: STYLE: unterminated quoted argument
mandoc: ./sys-utils/dmesg.1:33:2: WARNING: skipping paragraph macro: PP empty
mandoc: ./sys-utils/dmesg.1:255:2: WARNING: skipping paragraph macro: br after sp

mandoc: ./sys-utils/flock.1:183:2: WARNING: line scope broken: TQ breaks TP
mandoc: ./sys-utils/flock.1:43:2: WARNING: skipping paragraph macro: PP after SH

mandoc: ./sys-utils/fsfreeze.8:79:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./sys-utils/fsfreeze.8:83:2: WARNING: skipping paragraph macro: PP after SH

mandoc: ./sys-utils/ipcmk.1:43:2: WARNING: skipping paragraph macro: PP empty

mandoc: ./sys-utils/lsirq.1:16:11: STYLE: unterminated quoted argument
mandoc: ./sys-utils/lsirq.1:31:11: STYLE: unterminated quoted argument
mandoc: ./sys-utils/lsirq.1:34:11: STYLE: unterminated quoted argument

mandoc: ./sys-utils/mount.8:901:4: STYLE: unterminated quoted argument
mandoc: ./sys-utils/mount.8:2239:38: STYLE: unterminated quoted argument
mandoc: ./sys-utils/mount.8:88:2: WARNING: skipping paragraph macro: br after sp
mandoc: ./sys-utils/mount.8:90:2: WARNING: skipping paragraph macro: br before sp

mandoc: ./sys-utils/mountpoint.1:50:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./sys-utils/mountpoint.1:57:2: WARNING: skipping paragraph macro: PP after SH

mandoc: ./sys-utils/readprofile.8:10:2: WARNING: skipping paragraph macro: PP after SH
mandoc: ./sys-utils/readprofile.8💯2: WARNING: skipping paragraph macro: PP after SH

mandoc: ./sys-utils/renice.1:65:11: STYLE: unterminated quoted argument
mandoc: ./sys-utils/renice.1:68:11: STYLE: unterminated quoted argument
mandoc: ./sys-utils/renice.1:72:11: STYLE: unterminated quoted argument
mandoc: ./sys-utils/renice.1:55:2: WARNING: skipping paragraph macro: PP empty

mandoc: ./sys-utils/swapon.8:227:2: WARNING: skipping paragraph macro: br after SH

mandoc: ./sys-utils/unshare.1:350:32: STYLE: unterminated quoted argument
mandoc: ./sys-utils/unshare.1:253:2: WARNING: skipping paragraph macro: PP after SH

####

  The ouput from "nroff" and "groff" is unchanged.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
2020-06-15 11:28:01 +02:00
Bjarni Ingi Gislason a0859be5c7 doc: Fix some warnings from "test-groff" for manuals
Source is current git content.

Output is from: test-groff -b -e -mandoc -T utf8 -rF0 -t -w w -z

  [ "test-groff" is a developmental version of "groff" ]

Input file is ././disk-utils/sfdisk.8

troff: backtrace: file '<./disk-utils/sfdisk.8>':67
troff: <./disk-utils/sfdisk.8>:67: warning: trailing space

Input file is ././misc-utils/kill.1

troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-ext.tmac':133: macro 'EE'
troff: backtrace: file '<./misc-utils/kill.1>':167
troff: <./misc-utils/kill.1>:167: warning: macro 'mF' not defined
troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-ext.tmac':134: macro 'EE'
troff: backtrace: file '<./misc-utils/kill.1>':167
troff: <./misc-utils/kill.1>:167: warning: number register 'mE' not defined
troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-ext.tmac':134: macro 'EE'
troff: backtrace: file '<./misc-utils/kill.1>':167
troff: <./misc-utils/kill.1>:167: warning: bad font number
troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-ext.tmac':135: macro 'EE'
troff: backtrace: file '<./misc-utils/kill.1>':167
troff: <./misc-utils/kill.1>:167: warning: number register 'sP' not defined
troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-ext.tmac':134: macro 'EE'
troff: backtrace: file '<./misc-utils/kill.1>':170
troff: <./misc-utils/kill.1>:170: warning: bad font number

Input file is ././sys-utils/ipcs.1

<./sys-utils/ipcs.1>:103 (macro BR): only 1 argument, but more are expected

Input file is ././sys-utils/mount.8

<./sys-utils/mount.8>:68 (macro RB): only 1 argument, but more are expected
troff: backtrace: '/home/bg/git/groff/build/s-tmac/an-old.tmac':467: macro 'RB'
troff: backtrace: file '<./sys-utils/mount.8>':68
troff: <./sys-utils/mount.8>:68: warning [p 1, 3.5i]: can't break line
an-old.tmac: <./sys-utils/mount.8>:201 (.RE): warning: extra .RE or .RS is missing before it; "an-RS-open" is 0.
<./sys-utils/mount.8>:453 (macro BR): only 1 argument, but more are expected
<./sys-utils/mount.8>:500 (macro BR): only 1 argument, but more are expected
<./sys-utils/mount.8>:1050 (macro BR): only 1 argument, but more are expected

Input file is ././sys-utils/setpriv.1

<./sys-utils/setpriv.1>:17 (macro BR): only 1 argument, but more are expected
<./sys-utils/setpriv.1>:154 (macro BR): only 1 argument, but more are expected
<./sys-utils/setpriv.1>:166 (macro BR): only 1 argument, but more are expected

Input file is ././sys-utils/umount.8

<./sys-utils/umount.8>:145 (macro IR): only 1 argument, but more are expected

Input file is ././sys-utils/unshare.1

<./sys-utils/unshare.1>:266 (macro BR): only 1 argument, but more are expected

[kzak@redhat.com: - add .RS to fix extra .RE in mount.8]

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-10 10:22:58 +02:00
Marcel Waldvogel 07e6f72822 mount: Update man page Synopsis
Document
- `-t` when listing mounts
- `--bind`, `--rbind`, and `--move`
- `--make-*`
- Mountpoints need not only be directories

[kzak@redhat.com: - cleanup syntax,
		  - use all complete --make-* list]

Signed-off-by: Karel Zak <kzak@redhat.com>
2020-06-08 14:30:03 +02:00