X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-blkid.c;h=6ff244e96ce5387d70c07d99dc92dbc6576a82cb;hb=e7145211c73493080512e1623c42e085f54209f6;hp=0b1ae706e70607a39f7c77a7c29d9f49f558b8d4;hpb=e4b0e862252ac5c50c533b46dfe839b7c45639ac;p=thirdparty%2Fsystemd.git diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index 0b1ae706e70..6ff244e96ce 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -1,5 +1,4 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - +/* SPDX-License-Identifier: GPL-2.0+ */ /* * probe disks for filesystems and partitions * @@ -20,7 +19,7 @@ * along with this program. If not, see . */ -#include +#include #include #include #include @@ -32,6 +31,7 @@ #include "sd-id128.h" #include "alloc-util.h" +#include "blkid-util.h" #include "efivars.h" #include "fd-util.h" #include "gpt.h" @@ -108,7 +108,7 @@ static void print_property(struct udev_device *dev, bool test, const char *name, static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) { -#if defined(GPT_ROOT_NATIVE) && defined(ENABLE_EFI) +#if defined(GPT_ROOT_NATIVE) && ENABLE_EFI _cleanup_free_ char *root_id = NULL; bool found_esp = false; @@ -124,7 +124,7 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) { errno = 0; pl = blkid_probe_get_partitions(pr); if (!pl) - return errno ? -errno : -ENOMEM; + return -errno ?: -ENOMEM; nvals = blkid_partlist_numof_partitions(pl); for (i = 0; i < nvals; i++) { @@ -149,11 +149,6 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) { if (sd_id128_equal(type, GPT_ESP)) { sd_id128_t id, esp; - unsigned long long flags; - - flags = blkid_partition_get_flags(pp); - if (flags & GPT_FLAG_NO_AUTO) - continue; /* We found an ESP, let's see if it matches * the ESP we booted from. */ @@ -169,6 +164,11 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) { found_esp = true; } else if (sd_id128_equal(type, GPT_ROOT_NATIVE)) { + unsigned long long flags; + + flags = blkid_partition_get_flags(pp); + if (flags & GPT_FLAG_NO_AUTO) + continue; /* We found a suitable root partition, let's * remember the first one. */ @@ -195,7 +195,7 @@ static int probe_superblocks(blkid_probe pr) { int rc; if (fstat(blkid_probe_get_fd(pr), &st)) - return -1; + return -errno; blkid_probe_enable_partitions(pr, 1); @@ -227,10 +227,9 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t int64_t offset = 0; bool noraid = false; _cleanup_close_ int fd = -1; - blkid_probe pr; + _cleanup_blkid_free_probe_ blkid_probe pr = NULL; const char *data; const char *name; - const char *prtype = NULL; int nvals; int i; int err = 0; @@ -266,8 +265,7 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE | - BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION | - BLKID_SUBLKS_BADCSUM); + BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION); if (noraid) blkid_probe_filter_superblocks_usage(pr, BLKID_FLTR_NOTIN, BLKID_USAGE_RAID); @@ -289,15 +287,6 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t err = probe_superblocks(pr); if (err < 0) goto out; - if (blkid_probe_has_value(pr, "SBBADCSUM")) { - if (!blkid_probe_lookup_value(pr, "TYPE", &prtype, NULL)) - log_warning("incorrect %s checksum on %s", - prtype, udev_device_get_devnode(dev)); - else - log_warning("incorrect checksum on %s", - udev_device_get_devnode(dev)); - goto out; - } /* If we are a partition then our parent passed on the root * partition UUID to us */ @@ -323,7 +312,6 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t if (is_gpt) find_gpt_root(dev, pr, test); - blkid_free_probe(pr); out: if (err < 0) return EXIT_FAILURE;