]> err.no Git - util-linux/commitdiff
blkid: fix udev output
authorKarel Zak <kzak@redhat.com>
Wed, 21 Jan 2009 16:01:22 +0000 (17:01 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:35:23 +0000 (23:35 +0100)
- uses the "safe" output for non-encoded values
- makes the print_udev_format() more readable

Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/bin/blkid.c

index a903f4e684751417d016d845e7ada86834877282..e65fdaff3683770450e76f311a1120d625548687 100644 (file)
@@ -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,