Commit Graph

12945 Commits

Author SHA1 Message Date
Karel Zak c7df0f42b7 lib/path: add more debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak a375d911c7 chcpu: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 9ce2fef0d7 ctrlaltdel: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak fcc4517cfd lib/path: make ul_path_read_ usable with NULL handler
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak f99148d6f5 rfkill: don't use lib/path
It seems like crazy overkill for this trivial purpose.

Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 8ca312798c chmem: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak e4319a105b lsmem: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 7eb8e47bcd lib/path: add ul_path_read_buffer()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak e74e5401e1 lib/path: add ul_path_get_abspath()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak a6f0da166e zramctl: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 3aa4775c2f lib/sysfs: fix ul_path_read_string() usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak efb17218ef libfdisk: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 708a58b665 libblkid: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 8c3d9cad1e lib/sysfs: add sysfs_blkdev_get_parent()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 866ac74f97 lib/sysfs: make possible to call sysfs_blkdev_deinit_path() in loop
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak d5878cabe6 lib/path: fix read string to be backwardly compatible
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak bcf445fd68 lib/path lib/sysfs: add debug
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 2569d2ca1f lib/loopdev: remove obsolete macro
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 7604f85fb6 lib/loopdev: use new ul_path_* API
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 83029ea577 lib/sysfs: add ul_new_sysfs_path() shortcut
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-21 13:07:46 +02:00
Karel Zak 5387c01517 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>
2018-06-21 12:56:16 +02:00
Karel Zak 1ed21c80ed 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>
2018-06-21 11:58:10 +02:00
Milan Broz 1b06b33dd0 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>
2018-06-19 17:05:42 +02:00
Sami Kerola bd6a253f69
more: remove function like preprocessor defines
Inlining code using preprocessor function like macros is bad for
readability, and prone to errors.  Besides this is a pager, who cares if
code is few milliseconds slower.

Requestee-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-06-18 20:19:33 +01:00
Sami Kerola 7cc31c18d7
more: remove global variables, add struct more_control
This is rather big change, but that is the only way to do this sort job.  To
keep this change relatively understandable only moves global variables to a
state structure.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-06-18 20:19:33 +01:00
Sami Kerola 82cfa6f20f
more: move couple functions
Earlier commit moved lots of functions to work without declarations, but to
be able to get rid of global variables few more moves is needed.

Reference: a8f98304e6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2018-06-18 20:19:33 +01:00
Andreas Henriksson aeda8dc3d0 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
2018-06-18 10:42:36 +02:00
Karel Zak e60b6df54e 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>
2018-06-14 13:05:00 +02:00
Karel Zak 99ab05a6b4 docs: update TODO
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 16:28:59 +02:00
Karel Zak c5b63d284f mount: add -N to man page helpers section
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 16:27:51 +02:00
Vaclav Dolezal 6e965d0f4a 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>
2018-06-11 16:20:08 +02:00
Vaclav Dolezal c1e70afedf 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>
2018-06-11 16:18:06 +02:00
Vaclav Dolezal d59766a648 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>
2018-06-11 16:16:32 +02:00
Vaclav Dolezal d45e8ef999 mount: document --namespace in man/help
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:13:36 +02:00
Vaclav Dolezal cddd2eaa27 libmount: switch namespace when appropriate
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:12:55 +02:00
Vaclav Dolezal 65ca7b5a9b libmount: support for namespaces for helpers
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:08:44 +02:00
Karel Zak de7ccabdfd libmount: make errno usable after mnt_context_set_target_ns()
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 16:06:17 +02:00
Vaclav Dolezal c3dc9a8bad umount: add support for namespaces
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 16:01:49 +02:00
Vaclav Dolezal 21edc0f71a mount: add support for namespaces
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-11 15:56:41 +02:00
Vaclav Dolezal 8342e5840d libmount: added error MNT_ERR_NAMESPACE
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 15:51:17 +02:00
Vaclav Dolezal 5cbf01b75d libmount: note namespaces in mnt_reset_context() docs
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-06-11 15:50:29 +02:00
Vaclav Dolezal 4917d842ea 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>
2018-06-11 15:49:48 +02:00
Karel Zak 921f63433e 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>
2018-06-11 12:36:32 +02:00
Karel Zak 3b3f43748f 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>
2018-06-11 11:14:56 +02:00
Karel Zak ddf287b4ec 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>
2018-06-08 11:42:48 +02:00
Karel Zak c3f5a0f1d4 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>
2018-06-07 12:05:08 +02:00
Karel Zak 2c4d86abda 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>
2018-06-06 15:57:24 +02:00
Karel Zak 641af90dce tests: add empty column test
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-04 15:27:54 +02:00
Karel Zak a797704d5d libsmartcols: don't print empty column
The commit 0f9f927b6f 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 '🅰️b\n' | column -t -s ':' -o ':'
 🅰️b

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

Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-06-04 15:20:28 +02:00
Karel Zak 6691d53797 mount: keep MS_MOVE as flag
The previous commit 4ebea84bb1 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>
2018-06-01 14:07:53 +02:00