]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
2 years agoMerge branch 'sys-utils-unshare-fork-signal-handling' of https://github.com/earlchew...
Karel Zak [Tue, 11 Jan 2022 12:55:20 +0000 (13:55 +0100)] 
Merge branch 'sys-utils-unshare-fork-signal-handling' of https://github.com/earlchew/util-linux

* 'sys-utils-unshare-fork-signal-handling' of https://github.com/earlchew/util-linux:
  unshare: Propagate inherited signal handling to forked child

2 years agoblkid: don't print all devices if only garbage specified
Karel Zak [Mon, 10 Jan 2022 15:32:44 +0000 (16:32 +0100)] 
blkid: don't print all devices if only garbage specified

There is small regression. The old version (before
64cfe6ac37631a6347bd4005c72dd2d37e737f5e) returns nothing when

  # blkid /dontexist

specified on command line.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: Propagate inherited signal handling to forked child
Earl Chew [Sun, 9 Jan 2022 22:01:21 +0000 (14:01 -0800)] 
unshare: Propagate inherited signal handling to forked child

In #1086, signal(3) is used along with SIG_IGN,
and SIG_DFL, to prevent premature termination of
the parent. The present approach causes the
forked child to have different inherited
signal handling behaviour than original
behaviour inherited by the parent.

$ /usr/bin/unshare cat /proc/self/status | grep Sig
SigQ:   0/15523
SigPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000000000
SigCgt: 0000000000000000

$ /usr/bin/unshare --fork cat /proc/self/status | grep Sig
SigQ:   0/15523
SigPnd: 0000000000000000
SigBlk: 0000000000000000
SigIgn: 0000000000004002
SigCgt: 0000000000000000

As a consequence, if the command is killed, the
outcome is different if --fork is used:

$ /usr/bin/unshare sh -c 'kill $$' ; echo $?
Terminated
143

$ /usr/bin/unshare --fork sh -c 'kill $$' ; echo $?
0

Instead use sigprocmask(2) to ensure that signal
handling behaviour is propagated from the grandparent
to the forked child.

Signed-off-by: Earl Chew <earl_chew@yahoo.com>
2 years agolibfdisk: (gpt) provide last LBA where is partitions array
Karel Zak [Fri, 7 Jan 2022 13:05:36 +0000 (14:05 +0100)] 
libfdisk: (gpt) provide last LBA where is partitions array

Addresses: https://github.com/util-linux/util-linux/issues/1554
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agosulogin: fix compiler warning [-Werror=implicit-fallthrough=]
Karel Zak [Fri, 7 Jan 2022 12:49:40 +0000 (13:49 +0100)] 
sulogin: fix compiler warning [-Werror=implicit-fallthrough=]

and make sure errno is reset before read()

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'syslog-su-pid' of https://github.com/thesamesam/util-linux
Karel Zak [Fri, 7 Jan 2022 12:47:58 +0000 (13:47 +0100)] 
Merge branch 'syslog-su-pid' of https://github.com/thesamesam/util-linux

* 'syslog-su-pid' of https://github.com/thesamesam/util-linux:
  su: use LOG_PID for syslog

2 years agosulogin: Display all kinds of errno during password input.
Shigeki Morishima [Wed, 21 Jul 2021 02:04:32 +0000 (11:04 +0900)] 
sulogin: Display all kinds of errno during password input.

If some error happens during password input, all kinds of errno will be
displayed for investigation of the problem.

Signed-off-by: Shigeki Morishima <s.morishima@fujitsu.com>
2 years agosu: use LOG_PID for syslog
Sam James [Fri, 7 Jan 2022 01:54:41 +0000 (01:54 +0000)] 
su: use LOG_PID for syslog

Enable PID in syslog lines for `su`.

In Gentoo Linux, we recently switched `su` providers from
shadow to util-linux.

It was notiiced that syslog output differs slightly
with util-linux (no PID):
```
Jan  7 20:00:50 localhost su: (to root) root on pts/5
Jan  7 20:00:50 localhost su: pam_unix(su:session): session opened for user root(uid=0) by sam(uid=0)
```
... whereas shadow's `su` gave (with PID):
```
Jan  7 20:52:50 localhost su[22245]: Successful su for root by root
Jan  7 20:52:50 localhost su[22245]: + /dev/pts/5 root:root
```

This change enables PID logging to give shadow-like syslog
output for `su`:
```
Jan  7 20:54:32 localhost su[10827]: (to root) root on pts/6
Jan  7 20:54:32 localhost su[10827]: pam_unix(su:session): session opened for user root(uid=0) by sam(uid=0)
```

Signed-off-by: Sam James <sam@gentoo.org>
2 years agolibfdisk: (gpt) make fdisk -x output more readable
Karel Zak [Thu, 6 Jan 2022 13:52:50 +0000 (14:52 +0100)] 
libfdisk: (gpt) make fdisk -x output more readable

The field "First LBA" is confusing; let's use "First usable LBA" as
it's the official UEFI name for the field.

Addresses: https://github.com/util-linux/util-linux/issues/1554
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoagetty: resolve tty name even if stdin is specified
tamz [Thu, 6 Jan 2022 10:56:58 +0000 (11:56 +0100)] 
agetty: resolve tty name even if stdin is specified

[kzak@redhat.com: - use "const" for options->tty (and friends)
                    as expected by get_terminal_name()]

Addresses: https://github.com/util-linux/util-linux/issues/1546
Signed-off-by: tamz <totemz@protonmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolosetup: Add missing pipe to man example for setting up loop device
Vojtech Trefny [Thu, 6 Jan 2022 08:11:27 +0000 (09:11 +0100)] 
losetup: Add missing pipe to man example for setting up loop device

"-f" and "loopdev" cannot be used together, the pipe was lost
when converting the man pages to asciidoc.

Signed-off-by: Vojtech Trefny <vtrefny@redhat.com>
2 years agolibsmartcols: fix lines groups for multi-line cells
Karel Zak [Wed, 5 Jan 2022 10:15:36 +0000 (11:15 +0100)] 
libsmartcols: fix lines groups for multi-line cells

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2031303
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibsmartcols: add multi-line cells to samples
Karel Zak [Wed, 5 Jan 2022 10:04:05 +0000 (11:04 +0100)] 
libsmartcols: add multi-line cells to samples

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agomeson: fix bash_completion.get_variable() use
Karel Zak [Tue, 4 Jan 2022 11:57:52 +0000 (12:57 +0100)] 
meson: fix bash_completion.get_variable() use

Addresses: https://github.com/util-linux/util-linux/pull/1549
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agotests: update mountinfo files
Karel Zak [Tue, 4 Jan 2022 11:55:25 +0000 (12:55 +0100)] 
tests: update mountinfo files

References: 166e87368ae88bf31112a30e078cceae637f4cdb
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agomeson: keep bash-completion symlinks in variable
Karel Zak [Tue, 4 Jan 2022 11:17:41 +0000 (12:17 +0100)] 
meson: keep bash-completion symlinks in variable

This is small consolidation, let's call meson_make_symlink from one
place in loop.

Addresses: https://github.com/util-linux/util-linux/pull/1549
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agobuild-sys: install lastb bash-completion
Karel Zak [Tue, 4 Jan 2022 11:05:58 +0000 (12:05 +0100)] 
build-sys: install lastb bash-completion

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibmount: remove support for deleted mount table entries
Karel Zak [Tue, 4 Jan 2022 09:37:55 +0000 (10:37 +0100)] 
libmount: remove support for deleted mount table entries

The "(deleted)" suffix has been originally used by kernel for deleted
mountpoints. Since kernel commit 9d4d65748a5ca26ea8650e50ba521295549bf4e3
(Dec 2014) kernel does not use this suffix for mount stuff in /proc at
all. Let's remove this support from libmount too.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agomount: (man) fix example
Karel Zak [Mon, 3 Jan 2022 12:23:54 +0000 (13:23 +0100)] 
mount: (man) fix example

Fixes: https://github.com/util-linux/util-linux/issues/1539
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'patch-3' of https://github.com/mariobl/util-linux
Karel Zak [Mon, 3 Jan 2022 12:19:25 +0000 (13:19 +0100)] 
Merge branch 'patch-3' of https://github.com/mariobl/util-linux

* 'patch-3' of https://github.com/mariobl/util-linux:
  lsfd.1.adoc: Fix markup
  man pages: Fix punctuation, wording and markup

2 years agoMerge branch 'master' of https://github.com/lishengyu/util-linux
Karel Zak [Mon, 3 Jan 2022 12:13:09 +0000 (13:13 +0100)] 
Merge branch 'master' of https://github.com/lishengyu/util-linux

* 'master' of https://github.com/lishengyu/util-linux:
  fdisk: when use fdisk -l, open device in nonblock mode

2 years agoMerge branch 'master' of https://github.com/HeroesLoveToRoujiamo/util-linux
Karel Zak [Mon, 3 Jan 2022 12:12:34 +0000 (13:12 +0100)] 
Merge branch 'master' of https://github.com/HeroesLoveToRoujiamo/util-linux

* 'master' of https://github.com/HeroesLoveToRoujiamo/util-linux:
  fdisk: open device in nonblock mode

2 years agoMerge branch 'meson' of https://github.com/t-8ch/util-linux
Karel Zak [Mon, 3 Jan 2022 12:06:47 +0000 (13:06 +0100)] 
Merge branch 'meson' of https://github.com/t-8ch/util-linux

* 'meson' of https://github.com/t-8ch/util-linux:
  meson: only install pkgconfig if library is built
  meson: install manpages and bash completions
  meson: install examples to correct directory
  meson: headers: Install headers
  meson: headers: use util-linux version of version defines

2 years agoMerge branch 'wording' of https://github.com/stoeckmann/util-linux
Karel Zak [Mon, 3 Jan 2022 12:03:40 +0000 (13:03 +0100)] 
Merge branch 'wording' of https://github.com/stoeckmann/util-linux

* 'wording' of https://github.com/stoeckmann/util-linux:
  Fix wording in comments and documentation

2 years agoMerge branch 'fix_in_man-page' of https://github.com/losh/util-linux
Karel Zak [Mon, 3 Jan 2022 12:03:06 +0000 (13:03 +0100)] 
Merge branch 'fix_in_man-page' of https://github.com/losh/util-linux

* 'fix_in_man-page' of https://github.com/losh/util-linux:
  Fix difference between short description and longer description by adding prefix

2 years agoMerge branch 'remove-duplicate' of https://github.com/surdina/util-linux
Karel Zak [Mon, 3 Jan 2022 12:01:30 +0000 (13:01 +0100)] 
Merge branch 'remove-duplicate' of https://github.com/surdina/util-linux

* 'remove-duplicate' of https://github.com/surdina/util-linux:
  Remove duplicate 'setlocale' call

2 years agoMerge branch 'typo_blkid_manpage' of https://github.com/sevenmaster/util-linux
Karel Zak [Mon, 3 Jan 2022 11:55:29 +0000 (12:55 +0100)] 
Merge branch 'typo_blkid_manpage' of https://github.com/sevenmaster/util-linux

* 'typo_blkid_manpage' of https://github.com/sevenmaster/util-linux:
  Fixed minor typo in blkid manpage

2 years agomeson: only install pkgconfig if library is built
Thomas Weißschuh [Thu, 30 Dec 2021 21:57:24 +0000 (22:57 +0100)] 
meson: only install pkgconfig if library is built

2 years agomeson: install manpages and bash completions
Thomas Weißschuh [Thu, 30 Dec 2021 15:35:03 +0000 (16:35 +0100)] 
meson: install manpages and bash completions

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agomeson: install examples to correct directory
Thomas Weißschuh [Thu, 30 Dec 2021 15:33:33 +0000 (16:33 +0100)] 
meson: install examples to correct directory

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agomeson: headers: Install headers
Thomas Weißschuh [Thu, 30 Dec 2021 15:31:10 +0000 (16:31 +0100)] 
meson: headers: Install headers

Fixes #1365

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agomeson: headers: use util-linux version of version defines
Thomas Weißschuh [Thu, 30 Dec 2021 15:30:14 +0000 (16:30 +0100)] 
meson: headers: use util-linux version of version defines

This matches what autotools is doing.

Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
2 years agoFix wording in comments and documentation
Tobias Stoeckmann [Thu, 30 Dec 2021 12:49:47 +0000 (13:49 +0100)] 
Fix wording in comments and documentation

No functional change involved.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 years agofdisk: when use fdisk -l, open device in nonblock mode
lishengyu [Thu, 30 Dec 2021 12:07:34 +0000 (20:07 +0800)] 
fdisk: when use fdisk -l, open device in nonblock mode

When autoclose is set (kernel default) opening a CD-rom
device causes the tray to close.

Signed-off-by: lishengyu <lishengyu@uniontech.com>
2 years agoRemove duplicate 'setlocale' call
Alexandra Surdina [Mon, 27 Dec 2021 17:18:23 +0000 (18:18 +0100)] 
Remove duplicate 'setlocale' call

Co-authored by: khaleesi <contact@khaleesicodes.com>
Co-authored by: stoeckmann <tobias@stoeckmann.org>

2 years agoFix difference between short description and longer description by adding prefix
LoSh [Mon, 27 Dec 2021 16:03:14 +0000 (17:03 +0100)] 
Fix difference between short description and longer description by adding prefix

2 years agoFixed minor typo in blkid manpage
95p [Mon, 27 Dec 2021 16:03:18 +0000 (17:03 +0100)] 
Fixed minor typo in blkid manpage

2 years agolscpu: add additional arm cpu part numbers
Ali Saidi [Fri, 17 Dec 2021 15:34:15 +0000 (09:34 -0600)] 
lscpu: add additional arm cpu part numbers

Add additional cpu part numbers I can find publicaly available

Signed-off-by: Ali Saidi <alisaidi@amazon.com>
2 years agolsfd.1.adoc: Fix markup
Mario Blättermann [Thu, 16 Dec 2021 12:40:40 +0000 (13:40 +0100)] 
lsfd.1.adoc: Fix markup

2 years agofdisk: open device in nonblock mode
changlianzhi [Thu, 16 Dec 2021 02:56:25 +0000 (10:56 +0800)] 
fdisk: open device in nonblock mode

When autoclose is set (kernel default) opening a CD-rom
device causes the tray to close.

Signed-off-by: changlianzhi <changlianzhi@uniontech.com>
2 years agoman pages: Fix punctuation, wording and markup
Mario Blättermann [Wed, 15 Dec 2021 14:03:05 +0000 (15:03 +0100)] 
man pages: Fix punctuation, wording and markup

2 years agosu: Verify default SIGCHLD handling.
Tobias Stoeckmann [Sat, 23 Oct 2021 11:44:23 +0000 (13:44 +0200)] 
su: Verify default SIGCHLD handling.

The SIGCHLD handler could have been ignored by parent process.
Make sure that we have default handling activated.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
2 years agofindmnt: (verify) add hint about systemctl daemon-reload
Karel Zak [Mon, 13 Dec 2021 12:34:42 +0000 (13:34 +0100)] 
findmnt: (verify) add hint about systemctl daemon-reload

Let's inform that systemd uses stuff older than fstab.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agomount: add hint about systemctl daemon-reload
Karel Zak [Mon, 13 Dec 2021 12:22:56 +0000 (13:22 +0100)] 
mount: add hint about systemctl daemon-reload

This commit implements an extra hint for systemd based distros to
inform users that units currently used by systemd are older than
fstab.  This situation is usually unwanted, and 'systemctl
daemon-reload' is recommended.

The message is printed only on terminal to avoid extra messages in
logs, etc.

Addresses: https://github.com/systemd/systemd/pull/20476
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoinclude/c: add cmp_timespec() and cmp_stat_mtime()
Karel Zak [Mon, 13 Dec 2021 12:19:18 +0000 (13:19 +0100)] 
include/c: add cmp_timespec() and cmp_stat_mtime()

It's like timercmp() in libc, but for timespec and for stat.st_mtim
(or stat.st_mtime for old struct stat versions).

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agobuild-sys: add USE_SYSTEMD
Karel Zak [Mon, 13 Dec 2021 12:13:05 +0000 (13:13 +0100)] 
build-sys: add USE_SYSTEMD

Add info that systemd support is expected for tools where we do not
link with any systemd libs, but we want to support some systemd stuff.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: check blkid_get_cache() return value [coverity scan]
Karel Zak [Fri, 10 Dec 2021 15:22:07 +0000 (16:22 +0100)] 
libblkid: check blkid_get_cache() return value [coverity scan]

CID 374488:  Error handling issues  (CHECKED_RETURN)
Calling "blkid_get_cache" without checking return value (as is done elsewhere 4 out of 5 times).

It's probably unnecessary as we check the cache pointer later, but let's
make it more robust for static analyzers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'lsfd-blkdev' of https://github.com/masatake/util-linux
Karel Zak [Fri, 10 Dec 2021 14:20:28 +0000 (15:20 +0100)] 
Merge branch 'lsfd-blkdev' of https://github.com/masatake/util-linux

* 'lsfd-blkdev' of https://github.com/masatake/util-linux:
  tests: (lsfd) call ts_skip_nonroot earlier
  lsfd: fix a typo in comment
  lsfd: declare local variables at the beginning of block
  tests: (lsfd) add a case for listing a fd opening a block device
  tests: (lsfd) add a factory for opening a block device to the helper command
  lsfd: use the list of block devices in /proc/devices for decoding SOURCE column
  lsfd: add a helper function for reading bdevs in /prode/devices
  lsfd: move the code for reading /proc/devices to lsfd.c

2 years agolibblkid/src/probe: check for ENOMEDIUM from ioctl(CDROM_LAST_WRITTEN)
Jeremi Piotrowski [Wed, 8 Dec 2021 17:09:53 +0000 (09:09 -0800)] 
libblkid/src/probe: check for ENOMEDIUM from ioctl(CDROM_LAST_WRITTEN)

The CD device on Azure VMs returns CDS_DISC_OK from CDROM_DRIVE_STATUS even
when no disc is present. In that case an ENOMEDIUM from CDROM_LAST_WRITTEN
follows. Catch that and return error to prevent probing which results in
hundreds of "unaligned transfer" warnings in the kernel logbuffer.

Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
2 years agotests: (lsfd) call ts_skip_nonroot earlier
Masatake YAMATO [Wed, 8 Dec 2021 15:33:49 +0000 (00:33 +0900)] 
tests: (lsfd) call ts_skip_nonroot earlier

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: fix a typo in comment
Masatake YAMATO [Wed, 8 Dec 2021 06:11:05 +0000 (15:11 +0900)] 
lsfd: fix a typo in comment

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: declare local variables at the beginning of block
Masatake YAMATO [Wed, 8 Dec 2021 05:55:06 +0000 (14:55 +0900)] 
lsfd: declare local variables at the beginning of block

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) add a case for listing a fd opening a block device
Masatake YAMATO [Wed, 8 Dec 2021 15:44:50 +0000 (00:44 +0900)] 
tests: (lsfd) add a case for listing a fd opening a block device

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) add a factory for opening a block device to the helper command
Masatake YAMATO [Wed, 8 Dec 2021 13:30:57 +0000 (22:30 +0900)] 
tests: (lsfd) add a factory for opening a block device to the helper command

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agofindmnt: add SOURCES column to print all devices with the same tag
Karel Zak [Thu, 9 Dec 2021 12:20:50 +0000 (13:20 +0100)] 
findmnt: add SOURCES column to print all devices with the same tag

It's the same like TARGETS for lsblk (the same device is possible to
mount on more mountpoints). Here in findmnt we support by a new column
SOURCES scenario when more devices (filesystems) use the same tag
(LABEL, UUID, e.g.).

For example:

$ findmnt --fstab -oTARGET,SOURCES --evaluate --json UUID=b45897ca-ffc4-4089-8404-5d6072f5aee1
{
   "filesystems": [
      {
         "target": "/mnt/test",
         "sources": [
             "/dev/sdb1", "/dev/sdc"
         ]
      }
   ]
}

Fixes: https://github.com/util-linux/util-linux/issues/1078
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agosfdisk add --backup-pt-sectors
Karel Zak [Thu, 9 Dec 2021 11:07:16 +0000 (12:07 +0100)] 
sfdisk add --backup-pt-sectors

The current option --backup is usable only when used with others sfdisk
commands. The new command --backup-pt-sectors create backup and exit.

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoisfdisk: improve --backup documentation
Karel Zak [Thu, 9 Dec 2021 09:56:07 +0000 (10:56 +0100)] 
isfdisk: improve --backup documentation

* add reference to backup section
* add note that backup is done always after startup
* remove TODO item about --backup, it seems that back after open is
  only way how we can make it with current libfdisk, because
  fdisk_locate_disklabel() returns current in-memory rather than on-disk
  situation.

Addresses: https://github.com/util-linux/util-linux/issues/850
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolslocks: add INODE and MAJ:MIN columns
Karel Zak [Wed, 8 Dec 2021 15:55:03 +0000 (16:55 +0100)] 
lslocks: add INODE and MAJ:MIN columns

This is useful for use-cases (for example shell scripts) where
we cannot filter by PIDs.

Addresses: https://github.com/util-linux/util-linux/issues/1527
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsfd: use the list of block devices in /proc/devices for decoding SOURCE column
Masatake YAMATO [Wed, 8 Dec 2021 14:41:52 +0000 (23:41 +0900)] 
lsfd: use the list of block devices in /proc/devices for decoding SOURCE column

For decoding the SOURCE column of a fd opening a block devices, the
origina code uses /proc/partitions only. However, this is not enough
for decoding /dev/nullb0. Though is is a block device node, the block
device behind the node is not listed in /proc/partitions.

This change uses the information min /proc/devices as the fallback of
/proc/partitions.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: add a helper function for reading bdevs in /prode/devices
Masatake YAMATO [Wed, 8 Dec 2021 14:48:09 +0000 (23:48 +0900)] 
lsfd: add a helper function for reading bdevs in /prode/devices

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agolsfd: move the code for reading /proc/devices to lsfd.c
Masatake YAMATO [Wed, 8 Dec 2021 14:02:45 +0000 (23:02 +0900)] 
lsfd: move the code for reading /proc/devices to lsfd.c

The original code is only for reading the names of character device
drivers. For making the code reusable in reading that of block device
drivers, rearrange the code an move it to the common area, lsfd.c.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agoprlimit: make syscall use more robust
Karel Zak [Wed, 8 Dec 2021 14:17:01 +0000 (15:17 +0100)] 
prlimit: make syscall use more robust

This is only cosmetic change to make code robust and compatible with
other spaces where we use syscall().

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'patch-1' of https://github.com/Delapouite/util-linux
Karel Zak [Wed, 8 Dec 2021 13:16:08 +0000 (14:16 +0100)] 
Merge branch 'patch-1' of https://github.com/Delapouite/util-linux

* 'patch-1' of https://github.com/Delapouite/util-linux:
  uuidgen.1.adoc: mention uuidparse in SEE ALSO

2 years agoMerge branch 'fix-overflow' of https://github.com/ChanthMiao/util-linux
Karel Zak [Wed, 8 Dec 2021 13:15:14 +0000 (14:15 +0100)] 
Merge branch 'fix-overflow' of https://github.com/ChanthMiao/util-linux

* 'fix-overflow' of https://github.com/ChanthMiao/util-linux:
  Fix integer overflow for alpha like linux

2 years agoMerge branch 'patch-2' of https://github.com/mariobl/util-linux
Karel Zak [Wed, 8 Dec 2021 13:13:36 +0000 (14:13 +0100)] 
Merge branch 'patch-2' of https://github.com/mariobl/util-linux

* 'patch-2' of https://github.com/mariobl/util-linux:
  lsfd.1.adoc: Improve punctuation and add translator comments
  lsfd.1.adoc: Fix yet another entry in the filter examples list
  lsfd.1.adoc: Fix wording and markup

2 years agouuidgen.1.adoc: mention uuidparse in SEE ALSO
Bruno Heridet [Tue, 7 Dec 2021 06:56:22 +0000 (07:56 +0100)] 
uuidgen.1.adoc: mention uuidparse in SEE ALSO

This indication mirrors the one found in uuidparse.1.adoc

2 years agolsfd.1.adoc: Improve punctuation and add translator comments
Mario Blättermann [Mon, 6 Dec 2021 19:11:17 +0000 (20:11 +0100)] 
lsfd.1.adoc: Improve punctuation and add translator comments

2 years agohardlink: make reflink detection more robust [coverity scan]
Karel Zak [Mon, 6 Dec 2021 09:39:00 +0000 (10:39 +0100)] 
hardlink: make reflink detection more robust [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoFix integer overflow for alpha like linux
chanthmiao [Sun, 5 Dec 2021 08:58:17 +0000 (16:58 +0800)] 
Fix integer overflow for alpha like linux

2 years agolsfd.1.adoc: Fix yet another entry in the filter examples list
Mario Blättermann [Thu, 2 Dec 2021 19:59:02 +0000 (20:59 +0100)] 
lsfd.1.adoc: Fix yet another entry in the filter examples list

2 years agolsfd.1.adoc: Fix wording and markup
Mario Blättermann [Thu, 2 Dec 2021 19:41:14 +0000 (20:41 +0100)] 
lsfd.1.adoc: Fix wording and markup

2 years agohardlink: use open(O_CREAT) with mode
Karel Zak [Thu, 2 Dec 2021 14:00:44 +0000 (15:00 +0100)] 
hardlink: use open(O_CREAT) with mode

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agotests: update hardlink output
Karel Zak [Thu, 2 Dec 2021 13:25:59 +0000 (14:25 +0100)] 
tests: update hardlink output

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohardlink: add reflinks support (add --reflinks and --skip-reflinks)
Karel Zak [Thu, 2 Dec 2021 13:15:49 +0000 (14:15 +0100)] 
hardlink: add reflinks support (add --reflinks and --skip-reflinks)

Let's make XFS and BTRFS users more happy. The option --skip-reflinks
forces hardlink to detect files with shared extends and --reflinks
forces hardlink to create clones (FICLONE ioctl) rather than
hardlinks.

Addresses: https://github.com/util-linux/util-linux/issues/1447
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: fix memory leak [coverity scan]
Karel Zak [Thu, 2 Dec 2021 09:24:56 +0000 (10:24 +0100)] 
unshare: fix memory leak [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohardlink: call size_to_human_string() only when necessary
Karel Zak [Wed, 1 Dec 2021 14:42:52 +0000 (15:42 +0100)] 
hardlink: call size_to_human_string() only when necessary

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohardlink: simplify file_link()
Karel Zak [Wed, 1 Dec 2021 14:38:50 +0000 (15:38 +0100)] 
hardlink: simplify file_link()

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agounshare: Document --map-{groups,users,auto}
Sean Anderson [Wed, 24 Nov 2021 18:26:18 +0000 (13:26 -0500)] 
unshare: Document --map-{groups,users,auto}

This documents the new options added in the previous few commits.
I have added another example to better demonstrate the these
options. The actual use is fairly straightforward, but the descriptions
are on the pithier side.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add option to automatically create user and group maps
Sean Anderson [Wed, 24 Nov 2021 18:26:17 +0000 (13:26 -0500)] 
unshare: Add option to automatically create user and group maps

This option is designed to handle the "garden path" user/group ID
mapping:

- The user has one big map in /etc/sub[u,g]id
- The user wants to map as many user and group IDs as they can,
  especially the first 1000 users and groups.

The "auto" map is designed to handle this. We find the first map
matching the current user, and then map the whole thing to the ID range
starting at ID 0.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add options to map blocks of user/group IDs
Sean Anderson [Wed, 24 Nov 2021 18:26:16 +0000 (13:26 -0500)] 
unshare: Add options to map blocks of user/group IDs

This adds the ability to map multiple user/group IDs when creating a new
user namespace. Regular processes cannot map any user other than the
effective user, so we need to use the setuid helpers newuidmap and
newgidmap, provided by shadow. Typically, users will be assigned blocks
of user/group IDs in /etc/sub{u,g}id, although it is also possible to
use NSS. There is a second advantage in using these helpers: because we
never write to /proc/self/gid_map, we don't have to disable setgroups.

Because the process of mapping IDs is almost identical, whether we are
mapping user IDs or group IDs, we put both in a common "map_range"
structure. These are read in by (ab)using string_to_idarray. In addition
to any map created with --map-users, we still need to handle a map of
size one created with --map-user. This makes constructing the helpers'
command line the trickiest part of the whole process. newuidmap/
newgidmap check to see if any ranges overlap before creating a mapping.
To avoid failing, we carve out a hole in the mapping for the singular
map. In the worst case, we may have three separate maps.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add some helpers for forking and synchronizing
Sean Anderson [Wed, 24 Nov 2021 18:26:15 +0000 (13:26 -0500)] 
unshare: Add some helpers for forking and synchronizing

There is (or rather, will be) a common pattern in unshare like

/* parent */ /* child */
fork()
do_some_work()
sync() wait();
do_more_work();
wait() exit();

where the parent has to do some tasks (unshare(), fork() again, etc)
before the child can do its work. At the moment this is implemented
explicitly with a pipe().

Add some helper functions to abstract this process away. In addition,
switch to eventfd() instead of pipe(). As the man page for eventfd(2)
notes,

> Applications can use an eventfd file descriptor instead of a pipe (see
> pipe(2)) in all cases where a pipe is used simply to signal events. The
> kernel overhead of an eventfd file descriptor is much lower than that of
> a pipe, and only one file descriptor is required (versus the two required
> for a pipe).

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agounshare: Add waitchild helper
Sean Anderson [Wed, 24 Nov 2021 18:26:14 +0000 (13:26 -0500)] 
unshare: Add waitchild helper

This refactors out the waitpid() logic into a function which will be
reused for the upcoming patches.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agoinclude/c: Add abs_diff macro
Sean Anderson [Wed, 24 Nov 2021 18:26:13 +0000 (13:26 -0500)] 
include/c: Add abs_diff macro

This macro calculates abs(a - b). It is especially useful for unsigned
numbers.

Signed-off-by: Sean Anderson <seanga2@gmail.com>
2 years agolibmount: disable mtab only on statfs() success only
Karel Zak [Wed, 1 Dec 2021 11:35:42 +0000 (12:35 +0100)] 
libmount: disable mtab only on statfs() success only

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolsns: fix compilation on old systems without linux/nsfs.h
Karel Zak [Tue, 30 Nov 2021 14:02:10 +0000 (15:02 +0100)] 
lsns: fix compilation on old systems without linux/nsfs.h

Addresses: https://github.com/util-linux/util-linux/pull/1521
Reported-by: Anatoly Pugachev <matorola@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolscpu: (arm) remove extra whitespace
Karel Zak [Tue, 30 Nov 2021 13:24:40 +0000 (14:24 +0100)] 
lscpu: (arm) remove extra whitespace

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoMerge branch 'mantypo' of https://github.com/vice/util-linux
Karel Zak [Tue, 30 Nov 2021 13:21:38 +0000 (14:21 +0100)] 
Merge branch 'mantypo' of https://github.com/vice/util-linux

* 'mantypo' of https://github.com/vice/util-linux:
  script.1.adoc: correct socond as second

2 years agoscript.1.adoc: correct socond as second
Vicente Jimenez Aguilar [Tue, 30 Nov 2021 11:07:54 +0000 (12:07 +0100)] 
script.1.adoc: correct socond as second

2 years agoAdd Earlier Phytium cores
panchenbo [Tue, 30 Nov 2021 06:25:57 +0000 (14:25 +0800)] 
Add Earlier Phytium cores

2 years agoMerge branch 'lsfd-test-normalize-protoname' of https://github.com/masatake/util...
Karel Zak [Mon, 29 Nov 2021 15:06:30 +0000 (16:06 +0100)] 
Merge branch 'lsfd-test-normalize-protoname' of https://github.com/masatake/util-linux

* 'lsfd-test-normalize-protoname' of https://github.com/masatake/util-linux:
  tests: (lsfd) normalize protoname before comparing

2 years agoMerge branch 'mkfds-fix-fd-leak-via-dup2' of https://github.com/masatake/util-linux
Karel Zak [Mon, 29 Nov 2021 15:04:53 +0000 (16:04 +0100)] 
Merge branch 'mkfds-fix-fd-leak-via-dup2' of https://github.com/masatake/util-linux

* 'mkfds-fix-fd-leak-via-dup2' of https://github.com/masatake/util-linux:
  tests: (lsfd) fix file descriptor leaks reported by coverity

2 years agoMerge branch 'lsfd--test-minor-fixes' of https://github.com/masatake/util-linux
Karel Zak [Mon, 29 Nov 2021 15:03:40 +0000 (16:03 +0100)] 
Merge branch 'lsfd--test-minor-fixes' of https://github.com/masatake/util-linux

* 'lsfd--test-minor-fixes' of https://github.com/masatake/util-linux:
  tests: (lsfd) give missing test descriptions
  tests: (lsfd) don't compare inodes

2 years agoirqtop: don't ignore sscanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:32:27 +0000 (15:32 +0100)] 
irqtop: don't ignore sscanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agohwclock: don't ignore sscanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:30:10 +0000 (15:30 +0100)] 
hwclock: don't ignore sscanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agoutmpdump: don't ignore sscanf() return code [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:26:49 +0000 (15:26 +0100)] 
utmpdump: don't ignore sscanf() return code [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agolibblkid: ignore scanf() result when read number of stripes [coverity scan]
Karel Zak [Mon, 29 Nov 2021 14:21:55 +0000 (15:21 +0100)] 
libblkid: ignore scanf() result when read number of stripes [coverity scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
2 years agotests: (lsfd) fix file descriptor leaks reported by coverity
Masatake YAMATO [Mon, 29 Nov 2021 14:04:04 +0000 (23:04 +0900)] 
tests: (lsfd) fix file descriptor leaks reported by coverity

The oldfd argument of dup2 is not closed automatically.
It must be closed explicitly.

Close #1517.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) give missing test descriptions
Masatake YAMATO [Mon, 29 Nov 2021 14:12:23 +0000 (23:12 +0900)] 
tests: (lsfd) give missing test descriptions

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) don't compare inodes
Masatake YAMATO [Mon, 29 Nov 2021 14:01:04 +0000 (23:01 +0900)] 
tests: (lsfd) don't compare inodes

The numbers for the inodes (cwd and rtd) are different in platforms
(or file systems).

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2 years agotests: (lsfd) normalize protoname before comparing
Masatake YAMATO [Mon, 29 Nov 2021 13:26:03 +0000 (22:26 +0900)] 
tests: (lsfd) normalize protoname before comparing

This is a follow-up commit to a60ac11fe0087584f37329b4733edfade3452c64.

>    In the commit, the protoname of (AF_UNIX, SOCK_DGRAM) sockets was also
>    changed to "UNIX-DGRAM". However, it was renamed back to "UNIX" in
>    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0edf0824e0dc359ed76bf96af986e6570ca2c0b9

To make this test case more portable, this change makes the test case
accept "UINX-DGRAM" in addition to "UINX", too.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>