Now the code only checks that /sys/.../dm/name exists, but never
verify the device node in /dev (because path prefix is never NULL).
The prefix is used to redirect hardcoded paths to /sys dumps (e.g.
lsblk regression tests, etc.)
This bug has been introduced in v2.33. Fortunately, it's probably no
big issue as /dev is always in sync with /sys (thanks to udevd).
Signed-off-by: Karel Zak <kzak@redhat.com>
Old code:
./test_strutils --size 0.5MiB
0.5MiB : 512000 : 500K : 500 KiB
./test_strutils --size 0.50MiB
0.50MiB : 5120000 : 4.9M : 4.9 MiB
New code:
./test_strutils --size 0.5MiB
0.5MiB : 524288 : 512K : 512 KiB
./test_strutils --size 0.50MiB
0.50MiB : 524288 : 512K : 512 KiB
Note that the new implementation also does not use float points,
because we need to support PiB and so on... it seems good enough for
things like:
./test_strutils --size 7.13G
7.13G : 7656104581 : 7.1G : 7.1 GiB
./test_strutils --size 7.16G
7.16G : 7690675814 : 7.2G : 7.2 GiB
to avoid situation where cfdisk creates partition with completely
crazy numbers.
Addresses: https://github.com/karelzak/util-linux/issues/782
Signed-off-by: Karel Zak <kzak@redhat.com>
A recent bugfix in the Linux kernel made it possible for the
LOOP_SET_STATUS64 ioctl to fail when called with a non-zero offset,
with an EAGAIN errno:
5db470e229e2 loop: drop caches if offset or block_size are changed
This fix changes a silent failure (where mount could sometimes access
the backing loop image through the cache without the specified offset)
to an explicit failure, and it has also been backported on stable
branches.
On a 5.0 kernel, other changes to the loop driver make it hard to get
generate the EAGAIN error, but this bugfix has also been backported to
stables branches, without these changes. At least with the 4.14 stable
branch, the EAGAIN error can be quickly generated with the following loop:
while mount -o loop,offset=239 disk point && umount point; do :; done
Retry the ioctl when it fails with EAGAIN, which means that mount or
losetup will eventually succeed when encountering this case.
[kzak@redhat.com: - use our local portable xusleep()]
Signed-off-by: Romain Izard <romain.izard.pro@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
taskset hangs when executed with badly formatted cpuset list, for
example:
$ taskset -c 0--1 true
The current cpuset list parser is pretty weak as based on scanf()
without strings verification ("-1" as input for "%u" returns
unexpected number). It seems faster and better to use strtoul() and
isdigit().
Addresses: https://github.com/karelzak/util-linux/issues/77
Signed-off-by: Karel Zak <kzak@redhat.com>
The partition scanner in kernel depends on blocksize. We need to set
the blocksize before we call LOOP_SET_STATUS64 (this ioctl triggers
the scanner).
This patch extends the internal API to save blocksize into loopdev
context to be usable later for loopcxt_setup_device().
Signed-off-by: Karel Zak <kzak@redhat.com>
Now the internal API uses loopcxt_set_...() to set context variables
as well as to call ioctls. This patch introduces loopcxt_ioctl_...()
to makes things more obvious to readers.
Signed-off-by: Karel Zak <kzak@redhat.com>
Assumption all years since 1970 have been exactly 365 days long has it's
problems when leap years happen. Lets use struct tm fields that are
provided by localtime_r(), making year and day to be correctly compared even
when it's late new years eve somewhere else than UTC-0.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* add struct ul_timer as API abstraction to hide differences between
timer_create() and setitimer()
* add setitimer() detection to ./configure.ac
* add fallback code to use setitimer() if timer_create() not available
(for example on OSX)
Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
Accessing FUSE mounts require suid/sgid (saved uid) to be equal to the
owner of the mount. If mount is running as a setuid process, swapping
creds by only setting the euid/egid isn't enough to change the
suid/sgid as well. We must do a full setuid()/setgid(), but that
removes our ability to re-assume the identity of the original
euid. The solution is swap creds in a child process, preserving the
creds of the parent.
[kzak@redhat.com: - use switch() rather than if() for fork
- use all-io.h
- close unused pipe[] ends
- be more strict about used types]
Addresses: https://github.com/karelzak/util-linux/pull/705
Co-Author: Karel Zak <kzak@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
* don't cast from char to const char
* don't share endptr from strtoxxx() with rest of the code
as the end pointer is char, but code works with const chars
Signed-off-by: Karel Zak <kzak@redhat.com>
[util-linux-2.32.1/lib/strutils.c:122]: (style) Redundant condition: If 'EXPR == '0'', the comparison 'EXPR' is always true.
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/pager.c: In function ‘pager_preexec’:
lib/pager.c:148:12: warning: passing argument 2 to restrict-qualified parameter aliases with argument 4 [-Wrestrict]
Signed-off-by: Karel Zak <kzak@redhat.com>