* 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>
* 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>
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>
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>
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
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>
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>