From d46c8ab3e0e383bedb922a1c15d9aa5a49371026 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 21 Jan 2009 17:01:22 +0100 Subject: [PATCH] blkid: fix udev output - uses the "safe" output for non-encoded values - makes the print_udev_format() more readable Signed-off-by: Karel Zak --- libs/blkid/bin/blkid.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/libs/blkid/bin/blkid.c b/libs/blkid/bin/blkid.c index a903f4e6..e65fdaff 100644 --- a/libs/blkid/bin/blkid.c +++ b/libs/blkid/bin/blkid.c @@ -234,26 +234,25 @@ static void pretty_print_dev(blkid_dev dev) static void print_udev_format(const char *name, const char *value, size_t sz) { char enc[265], safe[256]; - int has_enc_name = 0; *safe = *enc = '\0'; - if (!strcmp(name, "TYPE") || !strcmp(name, "VERSION")) + if (!strcmp(name, "TYPE") || !strcmp(name, "VERSION")) { blkid_encode_string(value, enc, sizeof(enc)); + printf("ID_FS_%s=%s\n", name, enc); - else if (!strcmp(name, "UUID") || + } else if (!strcmp(name, "UUID") || !strcmp(name, "LABEL") || !strcmp(name, "UUID_SUB")) { blkid_safe_string(value, safe, sizeof(safe)); - blkid_encode_string(value, enc, sizeof(enc)); - has_enc_name = 1; - } - - printf("ID_FS_%s=%s\n", name, *enc ? enc : *safe ? safe : value); + printf("ID_FS_%s=%s\n", name, safe); - if (*enc && has_enc_name) + blkid_encode_string(value, enc, sizeof(enc)); printf("ID_FS_%s_ENC=%s\n", name, enc); + } + else + printf("ID_FS_%s=%s\n", name, value); } static void print_value(int output, int num, blkid_dev dev, -- 2.39.5