X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fudev%2Fudev-builtin-blkid.c;h=03e3dc2867bd814de876e8e142da1b80e469cc53;hb=51ddf61540976fc7b09ce5ace707b27f3acc3871;hp=a49dd31b8b28056d604894ea632041b418df94ab;hpb=cbd353ce7787ab11a9aa193f35abb97548b3fcf2;p=elogind.git diff --git a/src/udev/udev-builtin-blkid.c b/src/udev/udev-builtin-blkid.c index a49dd31b8..03e3dc286 100644 --- a/src/udev/udev-builtin-blkid.c +++ b/src/udev/udev-builtin-blkid.c @@ -34,8 +34,7 @@ #include "efivars.h" #include "udev.h" -static void print_property(struct udev_device *dev, bool test, const char *name, const char *value) -{ +static void print_property(struct udev_device *dev, bool test, const char *name, const char *value) { char s[256]; s[0] = '\0'; @@ -174,16 +173,15 @@ static int find_gpt_root(struct udev_device *dev, blkid_probe pr, bool test) { } /* We found the ESP on this disk, and also found a root - * partition, nice! Let's export its UUID*/ + * partition, nice! Let's export its UUID */ if (found_esp && root_id) - udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT", root_id); + udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT_UUID", root_id); #endif return 0; } -static int probe_superblocks(blkid_probe pr) -{ +static int probe_superblocks(blkid_probe pr) { struct stat st; int rc; @@ -215,17 +213,17 @@ static int probe_superblocks(blkid_probe pr) return blkid_do_safeprobe(pr); } -static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test) -{ +static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool test) { + const char *root_partition; int64_t offset = 0; bool noraid = false; _cleanup_close_ int fd = -1; blkid_probe pr; const char *data; const char *name; + const char *prtype = NULL; int nvals; int i; - size_t len; int err = 0; bool is_gpt = false; @@ -259,7 +257,8 @@ 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_USAGE | BLKID_SUBLKS_VERSION | + BLKID_SUBLKS_BADCSUM); if (noraid) blkid_probe_filter_superblocks_usage(pr, BLKID_FLTR_NOTIN, BLKID_USAGE_RAID); @@ -274,24 +273,42 @@ static int builtin_blkid(struct udev_device *dev, int argc, char *argv[], bool t if (err < 0) goto out; - log_debug("probe %s %sraid offset=%llu", + log_debug("probe %s %sraid offset=%"PRIi64, udev_device_get_devnode(dev), - noraid ? "no" : "", (unsigned long long) offset); + noraid ? "no" : "", offset); 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 */ + root_partition = udev_device_get_property_value(dev, "ID_PART_GPT_AUTO_ROOT_UUID"); nvals = blkid_probe_numof_values(pr); for (i = 0; i < nvals; i++) { - if (blkid_probe_get_value(pr, i, &name, &data, &len)) + if (blkid_probe_get_value(pr, i, &name, &data, NULL)) continue; - len = strnlen((char *) data, len); - print_property(dev, test, name, (char *) data); + print_property(dev, test, name, data); + /* Is this a disk with GPT partition table? */ if (streq(name, "PTTYPE") && streq(data, "gpt")) is_gpt = true; + + /* Is this a partition that matches the root partition + * property we inherited from our parent? */ + if (root_partition && streq(name, "PART_ENTRY_UUID") && streq(data, root_partition)) + udev_builtin_add_property(dev, test, "ID_PART_GPT_AUTO_ROOT", "1"); } if (is_gpt) @@ -308,6 +325,6 @@ out: const struct udev_builtin udev_builtin_blkid = { .name = "blkid", .cmd = builtin_blkid, - .help = "filesystem and partition probing", + .help = "Filesystem and partition probing", .run_once = true, };