]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
6 years agodocs: add note about lsblk to TODO
Karel Zak [Fri, 15 Jun 2018 10:07:10 +0000 (12:07 +0200)] 
docs: add note about lsblk to TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: use new ul_path_* API
Karel Zak [Fri, 15 Jun 2018 09:59:29 +0000 (11:59 +0200)] 
lsblk: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: cleanup function names
Karel Zak [Fri, 15 Jun 2018 09:57:48 +0000 (11:57 +0200)] 
lib/sysfs: cleanup function names

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoblockdev: use new ul_path_* API
Karel Zak [Wed, 30 May 2018 09:24:40 +0000 (11:24 +0200)] 
blockdev: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agopartx: use new ul_path_* API
Karel Zak [Wed, 30 May 2018 08:47:09 +0000 (10:47 +0200)] 
partx: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoresizepart: use new ul_path_* API
Karel Zak [Wed, 30 May 2018 08:41:46 +0000 (10:41 +0200)] 
resizepart: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoblkzone: use new ul_path_* API
Karel Zak [Tue, 29 May 2018 10:59:03 +0000 (12:59 +0200)] 
blkzone: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agofstrim: use new ul_path_* API
Karel Zak [Tue, 29 May 2018 10:53:52 +0000 (12:53 +0200)] 
fstrim: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: improve debug message on redirect
Karel Zak [Tue, 29 May 2018 10:41:48 +0000 (12:41 +0200)] 
lib/path: improve debug message on redirect

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agofstrim: add --dry-run
Karel Zak [Tue, 29 May 2018 10:39:32 +0000 (12:39 +0200)] 
fstrim: add --dry-run

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agofstrim: use new ul_path_* API, improve sysfs context usage
Karel Zak [Tue, 29 May 2018 10:10:31 +0000 (12:10 +0200)] 
fstrim: use new ul_path_* API, improve sysfs context usage

* improve has_discard() function to initialize sysfs context only once
* use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: fix sysfs_blkdev_get_wholedisk()
Karel Zak [Tue, 29 May 2018 10:09:56 +0000 (12:09 +0200)] 
lib/sysfs: fix sysfs_blkdev_get_wholedisk()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: simplify debug message
Karel Zak [Fri, 25 May 2018 11:20:22 +0000 (13:20 +0200)] 
lib/path: simplify debug message

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolscpu: use new ul_path_* API
Karel Zak [Fri, 25 May 2018 10:51:55 +0000 (12:51 +0200)] 
lscpu: use new ul_path_* API

* use ul_path_* API for /sys/devices/system/cpu paths
* use ul_path_* API for /proc
* rename is_compatible() to is_devtree_compatible() as it works
  with the devices tree only

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: add ul_prefix_fopen(), improve cpuset funcs
Karel Zak [Fri, 25 May 2018 10:47:06 +0000 (12:47 +0200)] 
lib/path: add ul_prefix_fopen(), improve cpuset funcs

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: don't use extra '/'
Karel Zak [Thu, 24 May 2018 12:06:11 +0000 (14:06 +0200)] 
lib/path: don't use extra '/'

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoipcs: use new ul_path_* API
Karel Zak [Thu, 24 May 2018 11:50:52 +0000 (13:50 +0200)] 
ipcs: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: add more debug messages
Karel Zak [Fri, 18 May 2018 10:33:03 +0000 (12:33 +0200)] 
lib/path: add more debug messages

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agochcpu: use new ul_path_* API
Karel Zak [Fri, 18 May 2018 10:32:52 +0000 (12:32 +0200)] 
chcpu: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoctrlaltdel: use new ul_path_* API
Karel Zak [Thu, 17 May 2018 14:26:07 +0000 (16:26 +0200)] 
ctrlaltdel: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: make ul_path_read_ usable with NULL handler
Karel Zak [Thu, 17 May 2018 14:25:47 +0000 (16:25 +0200)] 
lib/path: make ul_path_read_ usable with NULL handler

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agorfkill: don't use lib/path
Karel Zak [Thu, 17 May 2018 14:05:39 +0000 (16:05 +0200)] 
rfkill: don't use lib/path

It seems like crazy overkill for this trivial purpose.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agochmem: use new ul_path_* API
Karel Zak [Thu, 17 May 2018 12:45:23 +0000 (14:45 +0200)] 
chmem: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsmem: use new ul_path_* API
Karel Zak [Thu, 17 May 2018 12:45:23 +0000 (14:45 +0200)] 
lsmem: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: add ul_path_read_buffer()
Karel Zak [Thu, 17 May 2018 13:42:37 +0000 (15:42 +0200)] 
lib/path: add ul_path_read_buffer()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: add ul_path_get_abspath()
Karel Zak [Thu, 17 May 2018 11:58:30 +0000 (13:58 +0200)] 
lib/path: add ul_path_get_abspath()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agozramctl: use new ul_path_* API
Karel Zak [Wed, 16 May 2018 12:08:11 +0000 (14:08 +0200)] 
zramctl: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: fix ul_path_read_string() usage
Karel Zak [Wed, 16 May 2018 12:06:02 +0000 (14:06 +0200)] 
lib/sysfs: fix ul_path_read_string() usage

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibfdisk: use new ul_path_* API
Karel Zak [Wed, 16 May 2018 11:22:38 +0000 (13:22 +0200)] 
libfdisk: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibblkid: use new ul_path_* API
Karel Zak [Wed, 16 May 2018 11:20:39 +0000 (13:20 +0200)] 
libblkid: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: add sysfs_blkdev_get_parent()
Karel Zak [Wed, 16 May 2018 11:20:01 +0000 (13:20 +0200)] 
lib/sysfs: add sysfs_blkdev_get_parent()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: make possible to call sysfs_blkdev_deinit_path() in loop
Karel Zak [Wed, 16 May 2018 10:52:47 +0000 (12:52 +0200)] 
lib/sysfs: make possible to call sysfs_blkdev_deinit_path() in loop

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: fix read string to be backwardly compatible
Karel Zak [Tue, 15 May 2018 12:11:38 +0000 (14:11 +0200)] 
lib/path: fix read string to be backwardly compatible

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path lib/sysfs: add debug
Karel Zak [Tue, 15 May 2018 11:43:29 +0000 (13:43 +0200)] 
lib/path lib/sysfs: add debug

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/loopdev: remove obsolete macro
Karel Zak [Tue, 15 May 2018 11:21:41 +0000 (13:21 +0200)] 
lib/loopdev: remove obsolete macro

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/loopdev: use new ul_path_* API
Karel Zak [Tue, 15 May 2018 11:08:47 +0000 (13:08 +0200)] 
lib/loopdev: use new ul_path_* API

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: add ul_new_sysfs_path() shortcut
Karel Zak [Tue, 15 May 2018 11:08:18 +0000 (13:08 +0200)] 
lib/sysfs: add ul_new_sysfs_path() shortcut

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/sysfs: new implementation
Karel Zak [Fri, 11 May 2018 12:28:03 +0000 (14:28 +0200)] 
lib/sysfs: new implementation

* reuse ul_path_* API

* allow to use prefix for sysfs paths, so we can use snapshots from
  sysfs for regression tests

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolib/path: new implementation
Karel Zak [Wed, 9 May 2018 13:54:12 +0000 (15:54 +0200)] 
lib/path: new implementation

The goal is to avoid duplicate code in path.c and sysfs.c and make it
possible to define prefix for paths for all sysfs and procfs based
utils. Now we have /proc snapshots (for tests) for lscpu only. It
would be nice to have the same (for sysfs) for lsblk and another tools.

* very simple API to read numbers, strings and symlinks

* based on openat()

     pc = ul_new_path("/sys/block/sda");
     ul_path_read_u64(pc, &size, "size");
     ul_path_read_u64(pc, &lsz, "queue/logical_block_size");

* printf-like API to generate paths, for example:

     ul_path_readf_u64(pc, &num, "sda%d/size", partno)

* allow to define prefix to redirect hardcoded paths to another
  location, for example:

     pc = ul_new_path("/sys/block/sda");
     ul_path_set_prefix(pc, "/my/regression/dump");
     ul_path_read_u64(pc, &num, "size");

  to read /my/regression/dump/sys/block/sda/size

* allow to extend the API by "dialects", for example for sysfs:

     pc = ul_new_path(NULL);
     sysfs_blkdev_init_path(pc, devno, NULL);

  and use ul_path_* functions to read from @pc initialized by
  sysfs_blkdev_init_path()

* add test_path binary

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: add partition table UUID and type fields.
Milan Broz [Tue, 19 Jun 2018 10:33:20 +0000 (12:33 +0200)] 
lsblk: add partition table UUID and type fields.

This patch adds PTUUID and PTTYPE fields to lsblk, that are corresponding
fields to ID_PART_TABLE_UUID and ID_PART_TABLE_TYPE in udev database.

[kzak@redhat.com: - small change in PTUUID description]

Signed-off-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agopartx: exit with error code when partition read failed
Andreas Henriksson [Sun, 17 Jun 2018 12:49:15 +0000 (14:49 +0200)] 
partx: exit with error code when partition read failed

Make sure partx exits with a non-0 return code when
it runs into either code-path where getting the partition
table failed (or wasn't even attempted because of previous
error condition).

Change was tested using:
touch /tmp/foobar
partx -s - /tmp/foobar

Previously that was only printing an error/warning message
and then exiting with 0, but after this change it exits
with 1.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Reported-by: Juan Céspedes <cespedes@debian.org>
Addresses: https://bugs.debian.org/898426

6 years agosetarch: add another PER_LINUX32 aliases for ppcle
Karel Zak [Thu, 14 Jun 2018 11:02:49 +0000 (13:02 +0200)] 
setarch: add another PER_LINUX32 aliases for ppcle

The big-endian version maps generic "ppc" and "ppc32" aliases to
PER_LINUX32.  It seems that we can do the same for little-endian.

Note that SYS_personality does not care about LE/BE, it's 32 or 64 bit.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agodocs: update TODO
Karel Zak [Mon, 11 Jun 2018 14:28:59 +0000 (16:28 +0200)] 
docs: update TODO

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agomount: add -N to man page helpers section
Karel Zak [Mon, 11 Jun 2018 14:27:51 +0000 (16:27 +0200)] 
mount: add -N to man page helpers section

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoumount: fix behaviour of -A and -R with --namespace
Vaclav Dolezal [Tue, 24 Apr 2018 16:05:04 +0000 (18:05 +0200)] 
umount: fix behaviour of -A and -R with --namespace

Load /proc/self/mountinfo from correct namespace.

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoumount: allow PID as --namespace argument
Vaclav Dolezal [Fri, 20 Apr 2018 15:57:39 +0000 (17:57 +0200)] 
umount: allow PID as --namespace argument

[kzak@redhat.com: - update code]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agomount: allow PID as --namespace argument
Vaclav Dolezal [Fri, 20 Apr 2018 15:57:39 +0000 (17:57 +0200)] 
mount: allow PID as --namespace argument

[[kzak@redhat.com: - update code]

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agomount: document --namespace in man/help
Vaclav Dolezal [Tue, 17 Apr 2018 13:52:54 +0000 (15:52 +0200)] 
mount: document --namespace in man/help

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agolibmount: switch namespace when appropriate
Vaclav Dolezal [Wed, 11 Apr 2018 13:52:52 +0000 (15:52 +0200)] 
libmount: switch namespace when appropriate

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agolibmount: support for namespaces for helpers
Vaclav Dolezal [Tue, 6 Mar 2018 11:30:27 +0000 (12:30 +0100)] 
libmount: support for namespaces for helpers

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agolibmount: make errno usable after mnt_context_set_target_ns()
Karel Zak [Mon, 11 Jun 2018 14:06:17 +0000 (16:06 +0200)] 
libmount: make errno usable after mnt_context_set_target_ns()

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoumount: add support for namespaces
Vaclav Dolezal [Thu, 15 Mar 2018 13:06:48 +0000 (14:06 +0100)] 
umount: add support for namespaces

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agomount: add support for namespaces
Vaclav Dolezal [Mon, 19 Feb 2018 17:58:23 +0000 (18:58 +0100)] 
mount: add support for namespaces

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: added error MNT_ERR_NAMESPACE
Vaclav Dolezal [Tue, 13 Mar 2018 13:45:43 +0000 (14:45 +0100)] 
libmount: added error MNT_ERR_NAMESPACE

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agolibmount: note namespaces in mnt_reset_context() docs
Vaclav Dolezal [Tue, 20 Mar 2018 13:46:18 +0000 (14:46 +0100)] 
libmount: note namespaces in mnt_reset_context() docs

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
6 years agolibmount: add support for switching namespaces
Vaclav Dolezal [Mon, 19 Feb 2018 17:45:55 +0000 (18:45 +0100)] 
libmount: add support for switching namespaces

[kzak@redhat.com: - cosmetic changes, add some comments]

Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agowipefs: postpone BLKRRPART until all is done
Karel Zak [Mon, 11 Jun 2018 10:21:56 +0000 (12:21 +0200)] 
wipefs: postpone BLKRRPART until all is done

It's possible we erase from the whole device before we erase from the
partition on the same disk:

 # wipefs -a /dev/sdc /dev/sdc1

the current code calls re-read PT ioctl immediately after erase (so,
before sdc1 is processed). The result is that sdc1 node is no more
accessible:

  # wipefs -a /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc: calling ioctl to re-read partition table: Success
  wipefs: error: /dev/sdc1: probing initialization failed: No such file or directory

It seems the most simple solution is to postpone the re-read ioctl and
do it as the last thing.

  # wipefs -a  /dev/sdc /dev/sdc1
  /dev/sdc: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
  /dev/sdc1: 2 bytes were erased at offset 0x00000438 (ext4): 53 ef
  /dev/sdc: calling ioctl to re-read partition table: Success

The patch also adds a small delay before the re-read ioctl call. It's
not elegant, but without the usleep(25000) the first attempt returns
EBUSY.

Addresses: https://github.com/karelzak/util-linux/issues/598
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agozramctl: (man) explain that --find is necessary
Karel Zak [Mon, 11 Jun 2018 09:14:56 +0000 (11:14 +0200)] 
zramctl: (man) explain that --find is necessary

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1589148
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoblkzone: fix whole device detection
Karel Zak [Fri, 8 Jun 2018 09:37:55 +0000 (11:37 +0200)] 
blkzone: fix whole device detection

Matias Bjørling wrote:
  The current detection code for chunk size assumes that the
  underlying device is a device that uses the minor device id
  as the partition id, and that the whole device has minor id 0.
  This is not true for example null_blk and nvme device drivers.

Let's use sysfs_devno_to_wholedisk() to get whole-disk devno.

Addresses: https://github.com/karelzak/util-linux/pull/646
Reported-by: Matias Bjørling matias.bjorling@wdc.com
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolosetup: keep -f and <devname> mutually exclusive
Karel Zak [Thu, 7 Jun 2018 10:05:08 +0000 (12:05 +0200)] 
losetup: keep -f and <devname> mutually exclusive

losetup tries to blindly use specified device as well as search for
the first free device, the result is:

 # losetup /dev/loop1 -f /tmp/tfile_loop1
 losetup: /dev/loop1: failed to set up loop device: Invalid argument

fixed version:

 # losetup /dev/loop10 -f img
 losetup: unexpected arguments

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1566432
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoagetty: keep c_iflags unmodified on --autologin
Karel Zak [Wed, 6 Jun 2018 13:57:24 +0000 (15:57 +0200)] 
agetty: keep c_iflags unmodified on --autologin

agetty sets c_iflags according to interaction with serial line in
get_logname(). For --autologin it does not read from the line, so we
have no clue how to set the flags.

The current behavior is to zeroize the flags.  Unfortunately, it seems
like bad idea, because the line may be already properly initialized by
kernel (or systemd, etc.).

The new behavior is not touch the flags on --autologin.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1252764
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agotests: add empty column test
Karel Zak [Mon, 4 Jun 2018 13:27:54 +0000 (15:27 +0200)] 
tests: add empty column test

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibsmartcols: don't print empty column
Karel Zak [Mon, 4 Jun 2018 13:20:28 +0000 (15:20 +0200)] 
libsmartcols: don't print empty column

The commit 0f9f927b6f62cb7f488fadfad76c4a5defdefe36 forces
libsmartcols to use one byte as a minimal column width. This seems
like a bug if the column is empty and without header.

$ printf ':a:b\n' | column -t -s ':' -o ':'
 :a:b

Fixed version:
$ printf ':a:b\n' | column -t -s ':' -o ':'
:a:b

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agomount: keep MS_MOVE as flag
Karel Zak [Fri, 1 Jun 2018 12:07:53 +0000 (14:07 +0200)] 
mount: keep MS_MOVE as flag

The previous commit 4ebea84bb1ca6b0fa817588aba13de26c8d5e5a0 replaced
all operations by strings, but it does not work for MS_MOVE as this
operation is not supported in fstab by libmount.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: don't use MS_MGC_VAL magic in mount(2) syscall
Karel Zak [Fri, 1 Jun 2018 10:29:14 +0000 (12:29 +0200)] 
libmount: don't use MS_MGC_VAL magic in mount(2) syscall

Specifying MS_MGC_VAL was required in kernel versions prior to 2.4,
but since Linux 2.4 is no longer required and is ignored if specified

The minimal kernel requirement for util-linux is Linux v2.6.

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: improve MS_REC usage
Karel Zak [Fri, 1 Jun 2018 10:16:19 +0000 (12:16 +0200)] 
libmount: improve MS_REC usage

libmount allows to split one library (mount(8)) call to multiple mount(2)
syscalls, for example

   --rbind --make-rslave

in this case we have to be careful with MS_REC because the flag is
applied to multiple operations.

 # strace -e mount mount --rbind --make-rslave /mnt/A /mnt/B

Old version:

 mount("/mnt/A", "/mnt/B", 0x13ecac0, MS_MGC_VAL|MS_BIND, NULL) = 0
 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0

Fixed version:

 mount("/mnt/A", "/mnt/B", 0x1f22ac0, MS_MGC_VAL|MS_BIND|MS_REC, NULL) = 0
 mount("none", "/mnt/B", NULL, MS_REC|MS_SLAVE, NULL) = 0

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1584443
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agomount: use internally string to set move/bind operations
Karel Zak [Fri, 1 Jun 2018 10:11:03 +0000 (12:11 +0200)] 
mount: use internally string to set move/bind operations

It's better to inform libmount about operations by string than by
flags, because for example "rbind,slave" cannot be specified by
MS_REC|MS_BIND|MS_SLAVE.

https://bugzilla.redhat.com/show_bug.cgi?id=1584443
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: include sys/mount.h on Linux only
Karel Zak [Tue, 29 May 2018 08:06:00 +0000 (10:06 +0200)] 
libmount: include sys/mount.h on Linux only

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?att=1;bug=891812
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agopo: fix lsblk translation
Karel Zak [Tue, 29 May 2018 07:49:59 +0000 (09:49 +0200)] 
po: fix lsblk translation

Reported-by: Rosberg Nascimento Freitas Rodrigues <rosberg.berg@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibmount: accept another flags on MS_REMOUNT|MS_BIND
Karel Zak [Mon, 28 May 2018 13:46:28 +0000 (15:46 +0200)] 
libmount: accept another flags on MS_REMOUNT|MS_BIND

The current libmount MS_REMOUNT|MS_BIND support is restricted to
MS_RDONLY (read-only bind mount). This is too restrictive as Linux
kernel supports bind-remount for arbitrary VFS flags.

After this update you can use

 # mount /dev/sdc1 /mnt/A
 # mount --bind -onosuid,noexec /mnt/A /mnt/B

 # findmnt /dev/sdc1 -oTARGET,SOURCE,FS-OPTIONS,VFS-OPTIONS
 TARGET SOURCE    FS-OPTIONS                 VFS-OPTIONS
 /mnt/A /dev/sdc1 rw,stripe=512,data=ordered rw,relatime
 /mnt/B /dev/sdc1 rw,stripe=512,data=ordered rw,nosuid,noexec,relatime

The "mount --bind" is composed from two syscalls of course (1st is
bind, 2nd is bind,remount,nosuid,noexec).

Addresses: https://github.com/karelzak/util-linux/issues/637
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agomountpoint: simplify test condition [cppcheck]
Sami Kerola [Tue, 15 May 2018 19:14:05 +0000 (20:14 +0100)] 
mountpoint: simplify test condition [cppcheck]

[sys-utils/mountpoint.c:79]: (style) Redundant condition:
ctl->st.st_dev==pst.st_dev. 'A || (!A && B)' is equivalent to 'A || B'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agoinclude/pt-mbr.h: fix integer overflow
Sami Kerola [Sat, 12 May 2018 21:45:58 +0000 (22:45 +0100)] 
include/pt-mbr.h: fix integer overflow

gcc -fsanitize=undefined gives following warning.

include/pt-mbr.h:27:51: runtime error: left shift of 248 by 24 places cannot
be represented in type 'int'

It looks like char is converted internally to int before bit-shift, and that
type overflows when char value is greater than 127.  Following code snippet
will show the effect what is stored when undefined behaviour happens.

    #include <stdio.h>
    #include <inttypes.h>
    int main(int argc, unsigned char **argv)
    {
        char p[] = { 170, 170, 170, 170 };
        unsigned int uint = p[3];
        uint64_t res = 0;
        /* overflow */
        res = p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
        printf("%" PRIu64 "\n", res);
        /* this is fine */
        res = 0;
        res = p[0] | (p[1] << 8) | (p[2] << 16) | (uint << 24);
        printf("%" PRIu64 "\n", res);
        return 0;
    }

I tested gcc 8.1.0, clang 6.0.0, and tcc 0.9.27 and they all printed the
same values.

    $ ./a.out
    18446744073709551530
    4294967210

Because output is result of undefined behavior what is stored may change in
future, and other compilers / version might do something different.  In the
case of what pt-mbr.h the destination data type size was commonly 32 bits in
size, that truncated excess rubbish from bitshift.  Needless to say that was
not very robust code.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agonls: remove translation strings
Sami Kerola [Thu, 10 May 2018 20:18:53 +0000 (21:18 +0100)] 
nls: remove translation strings

While looking earlier commit I noticed everything but formatting was removed
from a message in namei.c file.  That inspired me to look if there are more
strings that does not need translation project attention.  This change
removes at least some of them, if not all.

Reference: e19cc7b65b31c57f0fe9cb73c9afad5197796f82
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agobash-completion: add swapon specifiers to completion
Sami Kerola [Thu, 10 May 2018 20:02:00 +0000 (21:02 +0100)] 
bash-completion: add swapon specifiers to completion

No space after device name is not entirely right, but that's better than
missing argument completions.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agorev: move a global variable to local scope
Sami Kerola [Wed, 9 May 2018 20:54:22 +0000 (21:54 +0100)] 
rev: move a global variable to local scope

Mark also file names read-only.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agotests: move stderr redirection out from test expression
Sami Kerola [Fri, 4 May 2018 19:38:03 +0000 (20:38 +0100)] 
tests: move stderr redirection out from test expression

Fix shellcheck error.

if ! [ "$paraller_jobs" -ge 0 2>/dev/null ]; then
^-- SC1009: The mentioned parser error was in this if expression.
     ^-- SC1073: Couldn't parse this test expression.
                              ^-- SC1072: Expected test to end here (don't
                                  wrap commands in []/[[]]). Fix any
                                  mentioned problems and try again.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolib/strutils: fix strnlen() fallback
Karel Zak [Mon, 28 May 2018 10:30:34 +0000 (12:30 +0200)] 
lib/strutils: fix strnlen() fallback

Addresses: https://github.com/karelzak/util-linux/issues/643
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoMerge branch 'master' of https://github.com/pali/util-linux
Karel Zak [Mon, 28 May 2018 07:58:19 +0000 (09:58 +0200)] 
Merge branch 'master' of https://github.com/pali/util-linux

* 'master' of https://github.com/pali/util-linux:
  libblkid: udf: Fix reporting UDF 2.60 revision

6 years agolibblkid: (ntfs) fix cluster size check
Karel Zak [Fri, 25 May 2018 19:02:23 +0000 (21:02 +0200)] 
libblkid: (ntfs) fix cluster size check

Addresses: https://github.com/karelzak/util-linux/issues/641
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolibblkid: udf: Fix reporting UDF 2.60 revision
Pali Rohár [Fri, 25 May 2018 15:52:31 +0000 (17:52 +0200)] 
libblkid: udf: Fix reporting UDF 2.60 revision

According to the UDF 2.60 specification, the Minimum UDF Read Revision
value shall be at most #0250 for all media with a UDF 2.60 file system.

So in this case use Minimum UDF Write Revision as ID_FS_VERSION to
distinguish between UDF 2.50 and UDF 2.60 discs.

This commit also adds a testing Blu-Ray Recordable image with UDF revision
2.60 created by Nero which really sets Minimum UDF Read Revision to 2.50.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
6 years agolibblkid: (ntfs) enlarge cluster limit to 2MB
Karel Zak [Fri, 25 May 2018 11:53:03 +0000 (13:53 +0200)] 
libblkid: (ntfs) enlarge cluster limit to 2MB

Windows 10 Creators edition has extended the ntfs cluster limit to
2MB. As a consequence blkid does not identify recent partitions with
clusters beyond 65K as ntfs ones.

Addresses: https://github.com/karelzak/util-linux/issues/641
Signed-off-by: Karel Zak <kzak@redhat.com>
Co-Author: Jean-Pierre André <jean-pierre.andre@wanadoo.fr>

6 years agocfdisk: fix compiler warnings, follow-up 7085f1e4 (#636)
Ruediger Meier [Thu, 24 May 2018 13:52:01 +0000 (15:52 +0200)] 
cfdisk: fix compiler warnings, follow-up 7085f1e4 (#636)

Seen on OSX 10.13, xcode 9.3.

 disk-utils/cfdisk.c:1860:45: error: format specifies type 'uintmax_t' (aka 'unsigned long') but the argument has type 'uint64_t' (aka 'unsigned long long') [-Werror,-Wformat]
         DBG(UI, ul_debug("get_size (default=%ju)", *res));
                                             ~~~    ^~~~
                                             %llu
 disk-utils/cfdisk.c:267:60: note: expanded from macro 'DBG'
 #define DBG(m, x)       __UL_DBG(cfdisk, CFDISK_DEBUG_, m, x)
                                                           ^
 ./include/debug.h:67:4: note: expanded from macro '__UL_DBG'
                         x; \
                         ^
 disk-utils/cfdisk.c:1889:25: error: incompatible pointer types passing 'uint64_t *' (aka 'unsigned long long *') to parameter of type 'uintmax_t *' (aka 'unsigned long *') [-Werror,-Wincompatible-pointer-types]
                         rc = parse_size(buf, &user, &pwr);      /* parse */
                                              ^~~~~
 ./include/strutils.h:15:51: note: passing argument to parameter 'res' here
 extern int parse_size(const char *str, uintmax_t *res, int *power);
                                                   ^
 2 errors generated.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
6 years agocfdisk: use uint64_t to avoid compiler warnings
Karel Zak [Thu, 24 May 2018 07:19:28 +0000 (09:19 +0200)] 
cfdisk: use uint64_t to avoid compiler warnings

Reported-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolslogins: add -o+<COLNAME> support
Karel Zak [Wed, 23 May 2018 14:44:42 +0000 (16:44 +0200)] 
lslogins: add -o+<COLNAME> support

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolslogins: add PWD-METHOD column
Karel Zak [Wed, 23 May 2018 14:32:32 +0000 (16:32 +0200)] 
lslogins: add PWD-METHOD column

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolslogins: fix password verification
Karel Zak [Wed, 23 May 2018 10:43:26 +0000 (12:43 +0200)] 
lslogins: fix password verification

Let's follow the standard $id$salt$encrypted password format in
verification code.

The current code is useless and for example PWD-LOCK column is always
FALSE.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1581611
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoman: Change the only argument to two for the two-fonts macros
Bjarni Ingi Gislason [Sat, 19 May 2018 00:09:56 +0000 (00:09 +0000)] 
man: Change the only argument to two for the two-fonts macros

  Punctuation marks have been left in the only argument of two-fonts
macros, instead of being separated from it to make the second one.

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
6 years agoman: choom.1: Use the correct macro for the font change of one argument
Bjarni Ingi Gislason [Sat, 19 May 2018 00:08:50 +0000 (00:08 +0000)] 
man: choom.1: Use the correct macro for the font change of one argument

  Use the correct macro "I" for one argument, instead of the
two-fonts macro "IR".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
6 years agoman: Use the correct macro for a font change of one argument
Bjarni Ingi Gislason [Fri, 18 May 2018 19:21:42 +0000 (19:21 +0000)] 
man: Use the correct macro for a font change of one argument

  Use the correct macro (I, B) for the font change of one argument, not
those that are used for alternating two fonts, like "BR", "IR", "RB",
or "RI".

Signed-off-by: Bjarni Ingi Gislason <bjarniig@rhi.hi.is>
6 years agomore: reorder global declarations
Sami Kerola [Thu, 19 Apr 2018 21:46:27 +0000 (22:46 +0100)] 
more: reorder global declarations

Group include, defines and such together, and move items inbetween functions
on top of the source file so that everything can be seen easily.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agomore: remove function prototypes
Sami Kerola [Thu, 19 Apr 2018 21:46:26 +0000 (22:46 +0100)] 
more: remove function prototypes

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
6 years agolsns: remove unnecessary include
Karel Zak [Thu, 17 May 2018 10:42:16 +0000 (12:42 +0200)] 
lsns: remove unnecessary include

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoscript: fix printf format specifiers
Ruediger Meier [Wed, 16 May 2018 10:37:17 +0000 (12:37 +0200)] 
script: fix printf format specifiers

Noticed on 32bit builds. Types changed in 0da73643.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
6 years agolsblk: fix notes about RAM disks
Karel Zak [Tue, 15 May 2018 08:51:15 +0000 (10:51 +0200)] 
lsblk: fix notes about RAM disks

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agolsblk: don't exclude RAM disks on --all
Karel Zak [Tue, 15 May 2018 08:29:22 +0000 (10:29 +0200)] 
lsblk: don't exclude RAM disks on --all

Reported-by: Milan Broz <gmazyland@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoiscript: s/COLS/COLUMNS/ in start message
Karel Zak [Mon, 14 May 2018 11:59:52 +0000 (13:59 +0200)] 
iscript: s/COLS/COLUMNS/ in start message

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agotests: update script done messages
Karel Zak [Mon, 14 May 2018 11:54:23 +0000 (13:54 +0200)] 
tests: update script done messages

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoscript: record exit code
Karel Zak [Mon, 14 May 2018 11:51:01 +0000 (13:51 +0200)] 
script: record exit code

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agotests: update script headers
Karel Zak [Mon, 14 May 2018 10:57:39 +0000 (12:57 +0200)] 
tests: update script headers

Signed-off-by: Karel Zak <kzak@redhat.com>
6 years agoscript: add more info to script header
Karel Zak [Mon, 14 May 2018 10:51:50 +0000 (12:51 +0200)] 
script: add more info to script header

This patch introduces [...] to store extra information about terminal
to the typescript header. For example:

  Script started on 2018-05-14 12:52:32+02:00 [TERM="xterm-256color" TTY="/dev/pts/3" COLS="190" LINES="53"]

or

  Script started on 2018-05-14 12:54:01+02:00 [<not executed on terminal>]

if stdout is not terminal.

Addresses: https://github.com/karelzak/util-linux/issues/583
Signed-off-by: Karel Zak <kzak@redhat.com>