Commit Graph

2867 Commits

Author SHA1 Message Date
Karel Zak 53b37016c3 meson: generate man pages from asciidoc
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-06 15:32:46 +02:00
Mario Blättermann 360946bb93 Asciidoc: Fix markup 2021-04-04 15:33:56 +02:00
Karel Zak 9dadd3e60c lscpu: report also number of cache instances
Caches (sum of all):
  L1d:                   128 KiB (4 instances)
  L1i:                   128 KiB (4 instances)
  L2:                    1 MiB (4 instances)
  L3:                    8 MiB (1 instance)

Suggested-by: John Henning <john.henning@oracle.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-01 12:27:05 +02:00
Karel Zak 625e9c61e8 build-sys: make man pages location independent
We need to evaluate "include::" directive relatively to project
top-level source directory rather than to the current document
location.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-31 11:50:47 +02:00
Karel Zak 25ce8fb1ed Merge remote-tracking branch 'mariobl/topic/asciidoc'
* mariobl/topic/asciidoc: (71 commits)
  Asciidoc: Update .pot template
  Asciidoc: Reorder example command sequence
  Asciidoc: Update .pot template
  Asciidoc: Better gettext message splitting in nsenter.1.adoc
  Asciidoc: Update .pot template
  Asciidoc: Fix typo and remove invisible spaces which confuse po4a
  Asciidoc: Update .pot template
  Asciidoc: Fix typo
  Asciidoc: Fix artifact from initial import, sixth attempt
  Asciidoc: Update .pot template
  Asciidoc: Fix artifacts from initial import, fifth attempt
  Asciidoc: Fix artifacts from initial import, fourth attempt
  Asciidoc: Update .pot template
  Asciidoc: Fix artifacts from initial import, third attempt
  Asciidoc: Fix artifacts from initial import, second attempt
  Asciidoc: Fix artifacts from initial import
  Asciidoc: Add po4a config file and initial translation template for man pages
  Asciidoc: Small indentation fix in mount.8.adoc
  Asciidoc: Review sys-utils man pages, part 2
  build-sys: fix out-of-tree build
  ...

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-29 15:09:27 +02:00
Mario Blättermann c8dae3d8fa Asciidoc: Reorder example command sequence 2021-03-28 14:29:45 +02:00
Mario Blättermann 86cc47aa51 Asciidoc: Better gettext message splitting in nsenter.1.adoc 2021-03-28 11:58:08 +02:00
Mario Blättermann 544e64e09e Asciidoc: Fix typo and remove invisible spaces which confuse po4a 2021-03-28 10:47:00 +02:00
Mario Blättermann f933e53c31 Asciidoc: Fix artifacts from initial import, fifth attempt 2021-03-26 21:41:03 +01:00
Mario Blättermann f67dbc88ca Asciidoc: Fix artifacts from initial import, fourth attempt 2021-03-26 21:11:25 +01:00
Mario Blättermann 9b7051d5bf Asciidoc: Fix artifacts from initial import, third attempt 2021-03-26 20:54:06 +01:00
Mario Blättermann 109525d66a Asciidoc: Fix artifacts from initial import, second attempt 2021-03-26 20:17:45 +01:00
Mario Blättermann b53360d8a8 Asciidoc: Fix artifacts from initial import 2021-03-26 20:12:42 +01:00
Mario Blättermann 9637ed960a Asciidoc: Small indentation fix in mount.8.adoc 2021-03-26 17:29:16 +01:00
Mario Blättermann 4eab78d379 Asciidoc: Review sys-utils man pages, part 2 2021-03-26 17:19:27 +01:00
Mario Blättermann fc86ec98de
Merge pull request #1 from karelzak/asciidoc-for-mario
Asciidoc for mario
2021-03-26 14:35:55 +01:00
Mario Blättermann 69dc8997dc Asciidoc: Incorporate latest changes in rfkill.8 and umount.8 2021-03-26 13:35:42 +01:00
Mario Blättermann b49072cf79 Asciidoc: Remove old man page links 2021-03-26 13:26:16 +01:00
Karel Zak 4f79d3032e build-sys: split man pages and man page links
The symlinks are generated by asciidoctor and current dist_man_MANS
depends on order (nan page before man link). This solutions is useless
when execute "make -j". The real solution is to keep man pages in
separate variable and use only this variable evaluate what we need to
generate.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-26 11:49:59 +01:00
Karel Zak c2096885af build-sys: remove man page link files
It seems asciidoctor generates all necessary files.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-26 11:26:08 +01:00
Mario Blättermann 68860732a7 Asciidoc: Review sys-utils man pages,part 1 2021-03-25 20:27:34 +01:00
Karel Zak 4397707e7a lsmem: use ul_path_readf_string() readable for analysers [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-25 12:23:21 +01:00
Karel Zak 01a895d840 lsirq: fix resources leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-25 12:14:46 +01:00
Karel Zak e37babc0ec lsirq: fix resources leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-25 12:13:00 +01:00
Karel Zak 645577c755 meson: add irq utils
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-25 12:12:11 +01:00
Karel Zak a887d587bf fstrim: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-25 11:53:02 +01:00
Karel Zak 20fae1bde2 rfkill: add "toggle" command
Addresses: https://github.com/karelzak/util-linux/issues/1269
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-23 15:20:44 +01:00
Karel Zak e2f6c9eaa2 umount: support over-mounts for --recursive
For example for hierarchy:

  $ findmnt -oTARGET,ID,PARENT
  TARGET                      ID PARENT
  /mnt/A                     802     62
  └─/mnt/A/B                 937    802
    ├─/mnt/A/B/C             964    937
    │ └─/mnt/A/B/C           991    964
    └─/mnt/A/B              1018    937
      └─/mnt/A/B            1045   1018

we need umount in order (id): 1045, 1018, 991, 964, 937, 802. The current
code first tries 991 in 937 branch.

Reported-by: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-22 11:29:28 +01:00
Mario Blättermann f42ed8190c Asciidoc: Unify spelling of »User Commands« 2021-03-21 10:00:16 +01:00
Mario Blättermann 295b3979d9 Asciidoc: Add Po4a hint to file headers 2021-03-20 16:42:47 +01:00
Mario Blättermann b4e57a8a90 Asciidoc: Small fix in nsenter.1.adoc 2021-03-20 15:23:32 +01:00
Mario Blättermann 5723eae791 Asciidoc: Some more man page formatting improvements
Besides some formatting tweaks, I've changed »lsblk(1)« into »lsblk(8)«
in the SEE ALSO section of mount.8.adoc. At least Archlinux and Debian
ship lsblk as a system administration command.
2021-03-20 09:45:23 +01:00
Mario Blättermann d315cc4d96 Asciidoc: Re-add empty lines to man pages 2021-03-19 20:52:00 +01:00
Mario Blättermann 4d29743519 Asciidoc: Some formatting cleanup in man pages 2021-03-19 18:25:50 +01:00
Karel Zak 1ad8db5521 prlimit: fix optional arguments parsing
$ prlimit -f=100:100
 failed to parse FSIZE limit

Fixes: https://github.com/karelzak/util-linux/issues/1265
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-18 10:23:36 +01:00
Karel Zak 308a097968 meson: update sources and dependencies
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-17 15:07:27 +01:00
Zbigniew Jędrzejewski-Szmek d4c880d5a4 meson: add second build system
To build: meson build && ninja -C build
To run tests: ninja -C build check
To install for packaging: DESTDIR=/var/tmp/inst ninja -C build install
To install for realz: sudo ninja -C build install

v2:
- Optional items are now based on the 'feature' feature in meson.
  Built libraries which are disabled turn into disabler() objects
  and also poison any executables which link to them.

What is there:
- building of the binaries and libs and the python module
- installation of binaries, libs, python module, localization files,
  man pages, pkgconfig files
- running of tests
- most options to configure build equivalently to the
  ./configure settings

Partially implemented:
- disabling of stuff when things missing. In the C code, the defines
  are all used, so that should be fine. In the build system, some
  files should be skipped, but that is probably not always done properly.
  Getting this right might require some testing of various build option
  combinations to get the details right.

Not implemented:
- static builds of fdisk and other binaries
- things marked with XXX or FIXME
- ???

Differences:
- .la files are not created. They are useless and everybody hates them.
- Requires.private in pkgconfig files are not present in the
  autogenerated .pc file. Not sure if they should be there or not. If
  necessary, they can be added by hand.
- man pages and systemd units are installed by the install target. Not
  sure why 'make install' doesn't do that.
- the split between / and /usr is probably wrong. But it's all pointless
  anyway, so maybe we could simplify things but not implementing it at
  all under meson?
2021-03-17 15:07:27 +01:00
Mario Blättermann ef63c72a33 Asciidoc: Fix man pages with variables to use the same value as in previous *.in files 2021-03-16 19:41:23 +01:00
Mario Blättermann b366e6fc6b Asciidoc: Remove already imported *roff man pages 2021-03-16 19:35:37 +01:00
Mario Blättermann 34455501de Asciidoc: Adapt Makefiles to new asciidoc man pages 2021-03-16 19:34:59 +01:00
Łukasz Stelmach c8650db343 hwclock: fix indentation
Fixes: 042f62dfc ("[clang-tidy] do not use else after return")
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
2021-03-16 14:23:48 +01:00
Mario Blättermann 84851dc21f Asciidoc: Import hwclock.8.in 2021-03-14 08:58:13 +01:00
Mario Blättermann fd8c150483 Asciidoc: Import rtcwake.8.in 2021-03-13 22:55:02 +01:00
Mario Blättermann b9d2ddfbb1 Asciidoc: Import sys-utils man pages, part 3 2021-03-13 22:33:34 +01:00
Mario Blättermann a09649ca89 Asciidoc: Use correct ':man manual:' for man pages from section 8 2021-03-13 12:49:26 +01:00
Mario Blättermann 1417968285 Asciidoc: Import sys-utils man pages, part 2 2021-03-13 12:22:34 +01:00
Mario Blättermann 6d5b69483a Asciidoc: Import sys-utils man pages, part 1 2021-03-12 21:10:37 +01:00
Karel Zak e0ecd19641 mountpoint: different exit status for errors and non-mountpoint situation
Fixes: https://github.com/karelzak/util-linux/issues/1260
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-11 10:48:36 +01:00
Karel Zak b4f6006209 lscpu: use size_t for ncolumns
Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-09 15:55:33 +01:00
Karel Zak 1242c3fde7 lscpu: support +list for -e, -p and -C
For example "lscpu -e=+MHZ" to list the default columns and MHZ. We
use the same in other tools.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-03-09 10:37:36 +01:00
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