diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-11-11 17:57:45 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-12-02 10:06:56 +0100 |
commit | 10c1b18888b4d4d2d07c175c2f68035c5dbca0f6 (patch) | |
tree | 1bd5aaf04ddc77e8ab8e9f96ff8b5c10ef1e4e9f | |
parent | 50d046993be9d830570d2571b670ad49204db92a (diff) | |
download | systemd-10c1b18888b4d4d2d07c175c2f68035c5dbca0f6.tar.gz |
valgrind: temporarily handle that valgrind still doesn't know LOOP_GET_STATUS64
Should be removed once valgrind learns it.
-rw-r--r-- | src/shared/dissect-image.c | 16 | ||||
-rw-r--r-- | src/shared/loop-util.c | 22 |
2 files changed, 33 insertions, 5 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index 934e0fe830..11d21c3a4d 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -1,5 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ +#if HAVE_VALGRIND_MEMCHECK_H +#include <valgrind/memcheck.h> +#endif + #include <linux/dm-ioctl.h> #include <linux/loop.h> #include <sys/mount.h> @@ -215,9 +219,15 @@ static int wait_for_partitions_to_appear( * an explicit recognizable error about this, so that callers can generate a * proper message explaining the situation. */ - if (ioctl(fd, LOOP_GET_STATUS64, &info) >= 0 && (info.lo_flags & LO_FLAGS_PARTSCAN) == 0) { - log_debug("Device is a loop device and partition scanning is off!"); - return -EPROTONOSUPPORT; + if (ioctl(fd, LOOP_GET_STATUS64, &info) >= 0) { +#if HAVE_VALGRIND_MEMCHECK_H + /* Valgrind currently doesn't know LOOP_GET_STATUS64. Remove this once it does */ + VALGRIND_MAKE_MEM_DEFINED(&info, sizeof(info)); +#endif + + if ((info.lo_flags & LO_FLAGS_PARTSCAN) == 0) + return log_debug_errno(EPROTONOSUPPORT, + "Device is a loop device and partition scanning is off!"); } } if (r != -EBUSY) diff --git a/src/shared/loop-util.c b/src/shared/loop-util.c index bbb85f9e6e..acf3eae2d7 100644 --- a/src/shared/loop-util.c +++ b/src/shared/loop-util.c @@ -1,5 +1,9 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ +#if HAVE_VALGRIND_MEMCHECK_H +#include <valgrind/memcheck.h> +#endif + #include <errno.h> #include <fcntl.h> #include <linux/blkpg.h> @@ -42,6 +46,11 @@ int loop_device_make_full( if (S_ISBLK(st.st_mode)) { if (ioctl(loop, LOOP_GET_STATUS64, &info) >= 0) { /* Oh! This is a loopback device? That's interesting! */ + +#if HAVE_VALGRIND_MEMCHECK_H + /* Valgrind currently doesn't know LOOP_GET_STATUS64. Remove this once it does */ + VALGRIND_MAKE_MEM_DEFINED(&info, sizeof(info)); +#endif nr = info.lo_number; if (asprintf(&loopdev, "/dev/loop%i", nr) < 0) @@ -217,9 +226,13 @@ int loop_device_open(const char *loop_path, int open_flags, LoopDevice **ret) { if (!S_ISBLK(st.st_mode)) return -ENOTBLK; - if (ioctl(loop_fd, LOOP_GET_STATUS64, &info) >= 0) + if (ioctl(loop_fd, LOOP_GET_STATUS64, &info) >= 0) { +#if HAVE_VALGRIND_MEMCHECK_H + /* Valgrind currently doesn't know LOOP_GET_STATUS64. Remove this once it does */ + VALGRIND_MAKE_MEM_DEFINED(&info, sizeof(info)); +#endif nr = info.lo_number; - else + } else nr = -1; p = strdup(loop_path); @@ -347,6 +360,11 @@ int loop_device_refresh_size(LoopDevice *d, uint64_t offset, uint64_t size) { if (ioctl(d->fd, LOOP_GET_STATUS64, &info) < 0) return -errno; +#if HAVE_VALGRIND_MEMCHECK_H + /* Valgrind currently doesn't know LOOP_GET_STATUS64. Remove this once it does */ + VALGRIND_MAKE_MEM_DEFINED(&info, sizeof(info)); +#endif + if (size == UINT64_MAX && offset == UINT64_MAX) return 0; if (info.lo_sizelimit == size && info.lo_offset == offset) |