]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: split blkid_parttable_set_id()
authorKarel Zak <kzak@redhat.com>
Thu, 13 Jun 2013 12:45:36 +0000 (14:45 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 13 Jun 2013 12:45:36 +0000 (14:45 +0200)
to avoid things like strcmp(tab->type, "gpt") in generic code.

Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/partitions/gpt.c
libblkid/src/partitions/partitions.c
libblkid/src/partitions/partitions.h

index ee98154a30046c42aaa9a12906b79c7be5d24781..6881c581044f1a7fa061830325b1edfaf4a01362 100644 (file)
@@ -340,7 +340,7 @@ static int probe_gpt_pt(blkid_probe pr,
        if (!tab)
                goto err;
 
-       blkid_parttable_set_id(tab, (const unsigned char *) &guid);
+       blkid_parttable_set_uuid(tab, (const unsigned char *) &guid);
 
        ssf = blkid_probe_get_sectorsize(pr) / 512;
 
index 20835c6df9549a74007036e2fb38cddbde6e0fdb..46631032af526dd292d3cc6c858f53f29e582802 100644 (file)
@@ -1001,16 +1001,21 @@ blkid_partition blkid_partlist_devno_to_partition(blkid_partlist ls, dev_t devno
        return NULL;
 }
 
-int blkid_parttable_set_id(blkid_parttable tab, const unsigned char *id)
+int blkid_parttable_set_uuid(blkid_parttable tab, const unsigned char *id)
 {
        if (!tab)
                return -1;
 
-       if (strcmp(tab->type, "gpt") == 0)
-               blkid_unparse_uuid(id, tab->id, sizeof(tab->id));
-       else if (strcmp(tab->type, "dos") == 0)
-               strncpy(tab->id, (const char *) id, sizeof(tab->id));
+       blkid_unparse_uuid(id, tab->id, sizeof(tab->id));
+       return 0;
+}
+
+int blkid_parttable_set_id(blkid_parttable tab, const unsigned char *id)
+{
+       if (!tab)
+               return -1;
 
+       strncpy(tab->id, (const char *) id, sizeof(tab->id));
        return 0;
 }
 
index 43f9a3cab605b2bfab4f866bbf9253ba643a3a9d..44423d9ccfe3e38890f738970140f36fb003011b 100644 (file)
@@ -9,6 +9,7 @@ extern int blkid_partitions_get_flags(blkid_probe pr);
 extern blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls,
                                const char *type, blkid_loff_t offset);
 
+extern int blkid_parttable_set_uuid(blkid_parttable tab, const unsigned char *id);
 extern int blkid_parttable_set_id(blkid_parttable tab, const unsigned char *id);
 
 extern blkid_partition blkid_partlist_add_partition(blkid_partlist ls,