]> err.no Git - systemd/commitdiff
volume_id: add internal UUID_STRING
authorKay Sievers <kay.sievers@vrfy.org>
Fri, 4 May 2007 14:53:19 +0000 (16:53 +0200)
committerKay Sievers <kay.sievers@vrfy.org>
Fri, 4 May 2007 14:53:19 +0000 (16:53 +0200)
15 files changed:
extras/volume_id/lib/ext.c
extras/volume_id/lib/fat.c
extras/volume_id/lib/hfs.c
extras/volume_id/lib/jfs.c
extras/volume_id/lib/linux_raid.c
extras/volume_id/lib/linux_swap.c
extras/volume_id/lib/luks.c
extras/volume_id/lib/netware.c
extras/volume_id/lib/ntfs.c
extras/volume_id/lib/ocfs.c
extras/volume_id/lib/reiserfs.c
extras/volume_id/lib/util.c
extras/volume_id/lib/util.h
extras/volume_id/lib/volume_id.c
extras/volume_id/lib/xfs.c

index 8b3af3aab07b995db5ee211b5860f20d376e9680..e5f1e22f6e8d754b1e80c848c77ed6b6e0652532 100644 (file)
@@ -93,7 +93,7 @@ int volume_id_probe_ext(struct volume_id *id, uint64_t off, uint64_t size)
 
        volume_id_set_label_raw(id, es->s_volume_name, 16);
        volume_id_set_label_string(id, es->s_volume_name, 16);
-       volume_id_set_uuid(id, es->s_uuid, UUID_DCE);
+       volume_id_set_uuid(id, es->s_uuid, 0, UUID_DCE);
        snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u",
                 le32_to_cpu(es->s_rev_level), le16_to_cpu(es->s_minor_rev_level));
 
index 9a2e4784d8cee165ca97f5b5a0d65c99e4456d92..6ed16ccee0ea2efa03c82695fdfb7eccd453f759 100644 (file)
@@ -288,7 +288,7 @@ magic:
                volume_id_set_label_raw(id, vs->type.fat.label, 11);
                volume_id_set_label_string(id, vs->type.fat.label, 11);
        }
-       volume_id_set_uuid(id, vs->type.fat.serno, UUID_DOS);
+       volume_id_set_uuid(id, vs->type.fat.serno, 0, UUID_DOS);
        goto found;
 
 fat32:
@@ -366,7 +366,7 @@ fat32:
                volume_id_set_label_raw(id, vs->type.fat32.label, 11);
                volume_id_set_label_string(id, vs->type.fat32.label, 11);
        }
-       volume_id_set_uuid(id, vs->type.fat32.serno, UUID_DOS);
+       volume_id_set_uuid(id, vs->type.fat32.serno, 0, UUID_DOS);
 
 found:
        volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
index 303ad6b041bd6c2d4793189ae62b3581bff179d3..8156008f6136e910116e171265b529fe38804626 100644 (file)
@@ -160,7 +160,7 @@ static void hfsid_set_uuid(struct volume_id *id, const uint8_t *hfs_id)
        volume_id_set_uuid(id, uuid, UUID_DCE);
 #endif
 
-       volume_id_set_uuid(id, hfs_id, UUID_HFS);
+       volume_id_set_uuid(id, hfs_id, 0, UUID_HFS);
 }
 
 int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off, uint64_t size)
index 6d4124cd05ea4657dc57ee221e1bd173b271301a..00b66cccc7ac98fc17e332ebd931341b41c3f529 100644 (file)
@@ -56,7 +56,7 @@ int volume_id_probe_jfs(struct volume_id *id, uint64_t off, uint64_t size)
 
        volume_id_set_label_raw(id, js->label, 16);
        volume_id_set_label_string(id, js->label, 16);
-       volume_id_set_uuid(id, js->uuid, UUID_DCE);
+       volume_id_set_uuid(id, js->uuid, 0, UUID_DCE);
 
        volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
        id->type = "jfs";
index 6f37e2a35871b3d3dab63b3d3315432140673df7..6d1d19cb740916552cea3cb6ff25484a51c10bd1 100644 (file)
@@ -87,7 +87,7 @@ static int volume_id_probe_linux_raid0(struct volume_id *id, uint64_t off, uint6
                        uuid.ints[2] = 0;
                        uuid.ints[3] = 0;
                }
-               volume_id_set_uuid(id, uuid.bytes, UUID_FOURINT);
+               volume_id_set_uuid(id, uuid.bytes, 0, UUID_FOURINT);
                snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
                         le32_to_cpu(mdp0->major_version),
                         le32_to_cpu(mdp0->minor_version),
@@ -103,7 +103,7 @@ static int volume_id_probe_linux_raid0(struct volume_id *id, uint64_t off, uint6
                        uuid.ints[2] = 0;
                        uuid.ints[3] = 0;
                }
-               volume_id_set_uuid(id, uuid.bytes, UUID_FOURINT);
+               volume_id_set_uuid(id, uuid.bytes, 0, UUID_FOURINT);
                snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
                         be32_to_cpu(mdp0->major_version),
                         be32_to_cpu(mdp0->minor_version),
@@ -131,7 +131,7 @@ static int volume_id_probe_linux_raid1(struct volume_id *id, uint64_t off, uint6
        if (le32_to_cpu(mdp1->magic) != MD_SB_MAGIC)
                return -1;
 
-       volume_id_set_uuid(id, mdp1->set_uuid, UUID_FOURINT);
+       volume_id_set_uuid(id, mdp1->set_uuid, 0, UUID_FOURINT);
        volume_id_set_label_raw(id, mdp1->set_name, 32);
        volume_id_set_label_string(id, mdp1->set_name, 32);
        snprintf(id->type_version, sizeof(id->type_version)-1, "%u", le32_to_cpu(mdp1->major_version));
index 8aca564d7276b8efdccb5f7b40d4accd788593ba..50d43ccce684dc65c0ca0f7e2f3feea9d4ba224f 100644 (file)
@@ -81,7 +81,7 @@ found_label:
        if (sw != NULL) {
                volume_id_set_label_raw(id, sw->volume_name, 16);
                volume_id_set_label_string(id, sw->volume_name, 16);
-               volume_id_set_uuid(id, sw->uuid, UUID_DCE);
+               volume_id_set_uuid(id, sw->uuid, 0, UUID_DCE);
        }
 
 found:
index a141a0f5c39d8ad31cb04b31f90399d8cfa9472e..231374e507f3893271428a83375acc73dcc2bc99 100644 (file)
 #define LUKS_SALTSIZE                  32
 #define LUKS_NUMKEYS                   8
 
+#define LUKS_MAGIC_L                   6
+#define LUKS_PHDR_SIZE                 (sizeof(struct luks_phdr)/SECTOR_SIZE+1)
+#define UUID_STRING_L                  40
 static const uint8_t LUKS_MAGIC[] = {'L','U','K','S', 0xba, 0xbe};
-#define LUKS_MAGIC_L 6
-#define LUKS_PHDR_SIZE (sizeof(struct luks_phdr)/SECTOR_SIZE+1)
-#define UUID_STRING_L 40
 
 struct luks_phdr {
        uint8_t         magic[LUKS_MAGIC_L];
@@ -74,9 +74,7 @@ int volume_id_probe_luks(struct volume_id *id, uint64_t off, uint64_t size)
                return -1;
 
        volume_id_set_usage(id, VOLUME_ID_CRYPTO);
-       volume_id_set_uuid(id, header->uuid, UUID_DCE_STRING);
-
+       volume_id_set_uuid(id, header->uuid, 36, UUID_HEX_STRING);
        id->type = "crypto_LUKS";
-
        return 0;
 }
index 67af56133102cd0935ec8b2630c7e5870a11fec5..4d157aaf5d4c5511ff2b0bcba92ab9bf8417f9c4 100644 (file)
@@ -91,7 +91,7 @@ int volume_id_probe_netware(struct volume_id *id, uint64_t off, uint64_t size)
        if (memcmp(nw->SBH_Signature, "SPB5", 4) != 0)
                return -1;
 
-       volume_id_set_uuid(id, nw->SBH_PoolID, UUID_DCE);
+       volume_id_set_uuid(id, nw->SBH_PoolID, 0, UUID_DCE);
 
        snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%02u",
                 le16_to_cpu(nw->SBH_VersionMediaMajor), le16_to_cpu(nw->SBH_VersionMediaMinor));
index f7675a3434396b267232604935e0aba65a44ba8a..6e91db687b53caa54cae3cdf25eddbd9a10e9762 100644 (file)
@@ -114,7 +114,7 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off, uint64_t size)
        if (memcmp(ns->oem_id, "NTFS", 4) != 0)
                return -1;
 
-       volume_id_set_uuid(id, ns->volume_serial, UUID_NTFS);
+       volume_id_set_uuid(id, ns->volume_serial, 0, UUID_NTFS);
 
        sector_size = le16_to_cpu(ns->bytes_per_sector);
        cluster_size = ns->sectors_per_cluster * sector_size;
index 349527b7e0638ca604b3cc56659f82ab1d704471..9f251f1794610940cc6d061910bcfd7e459f31e9 100644 (file)
@@ -156,7 +156,7 @@ int volume_id_probe_ocfs1(struct volume_id *id, uint64_t off, uint64_t size)
                volume_id_set_label_string(id, osl->label, 64);
        }
        if (osl->vol_id_len == 16)
-               volume_id_set_uuid(id, osl->vol_id, UUID_DCE);
+               volume_id_set_uuid(id, osl->vol_id, 0, UUID_DCE);
        id->type = "ocfs";
        return 0;
 }
@@ -184,7 +184,7 @@ int volume_id_probe_ocfs2(struct volume_id *id, uint64_t off, uint64_t size)
                volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
                volume_id_set_label_raw(id, os->s_label, 64);
                volume_id_set_label_string(id, os->s_label, 64);
-               volume_id_set_uuid(id, os->s_uuid, UUID_DCE);
+               volume_id_set_uuid(id, os->s_uuid, 0, UUID_DCE);
                snprintf(id->type_version, sizeof(id->type_version)-1,
                         "%u.%u", os->s_major_rev_level, os->s_minor_rev_level);
                id->type = "ocfs2";
index 1f219e5bded05eb698182658aa075ac91f2e98c7..18db63817a0687277d80ce70058e8afaa0380142 100644 (file)
@@ -88,7 +88,7 @@ int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off, uint64_t size)
                strcpy(id->type_version, "4");
                volume_id_set_label_raw(id, rs4->label, 16);
                volume_id_set_label_string(id, rs4->label, 16);
-               volume_id_set_uuid(id, rs4->uuid, UUID_DCE);
+               volume_id_set_uuid(id, rs4->uuid, 0, UUID_DCE);
                id->type = "reiser4";
                goto found;
        }
@@ -109,7 +109,7 @@ int volume_id_probe_reiserfs(struct volume_id *id, uint64_t off, uint64_t size)
 found_label:
        volume_id_set_label_raw(id, rs->label, 16);
        volume_id_set_label_string(id, rs->label, 16);
-       volume_id_set_uuid(id, rs->uuid, UUID_DCE);
+       volume_id_set_uuid(id, rs->uuid, 0, UUID_DCE);
 
 found:
        volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
index 762e84e170ca19eb7b1f492beb79eda9545febc9..d65fc2c1d653b1be6668c95eb97a2410d65ae88c 100644 (file)
@@ -115,11 +115,14 @@ void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enu
         volume_id_set_unicode16(id->label, sizeof(id->label), buf, endianess, count);
 }
 
-void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format)
+void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, size_t len, enum uuid_format format)
 {
        unsigned int i;
        unsigned int count = 0;
 
+       if (len > sizeof(id->uuid_raw))
+               len = sizeof(id->uuid_raw);
+
        switch(format) {
        case UUID_DOS:
                count = 4;
@@ -131,8 +134,11 @@ void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_form
        case UUID_DCE:
                count = 16;
                break;
-       case UUID_DCE_STRING:
-               count = 36;
+       case UUID_HEX_STRING:
+               count = len;
+               break;
+       case UUID_STRING:
+               count = len;
                break;
        case UUID_FOURINT:
                count = 35;
@@ -172,7 +178,12 @@ set:
                        buf[8], buf[9],
                        buf[10], buf[11], buf[12], buf[13], buf[14],buf[15]);
                break;
-       case UUID_DCE_STRING:
+       case UUID_HEX_STRING:
+               for (i = 0; i < count; i++)
+                       id->uuid[i] = tolower(buf[i]);
+               id->uuid[count] = '\0';
+               break;
+       case UUID_STRING:
                memcpy(id->uuid, buf, count);
                id->uuid[count] = '\0';
                break;
index 964e70196aac90029e69389829af6ddfa71b1fef..cd8dac557c1df727d889aa8f8cd3afa912a0e10e 100644 (file)
@@ -63,7 +63,8 @@
 #endif /* __BYTE_ORDER */
 
 enum uuid_format {
-       UUID_DCE_STRING,
+       UUID_HEX_STRING,
+       UUID_STRING,
        UUID_DCE,
        UUID_DOS,
        UUID_NTFS,
@@ -81,7 +82,7 @@ extern void volume_id_set_usage(struct volume_id *id, enum volume_id_usage usage
 extern void volume_id_set_label_raw(struct volume_id *id, const uint8_t *buf, size_t count);
 extern void volume_id_set_label_string(struct volume_id *id, const uint8_t *buf, size_t count);
 extern void volume_id_set_label_unicode16(struct volume_id *id, const uint8_t *buf, enum endian endianess, size_t count);
-extern void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, enum uuid_format format);
+extern void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, size_t len, enum uuid_format format);
 extern uint8_t *volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len);
 extern void volume_id_free_buffer(struct volume_id *id);
 
index bf009c72030383b8bcbcc47ec906c3102121914b..a66b4a5769c735638f59710eb24fbf360bd6f1f4 100644 (file)
@@ -146,6 +146,9 @@ int volume_id_probe_raid(struct volume_id *id, uint64_t off, uint64_t size)
                if (volume_id_probe_linux_raid(id, off, size) == 0)
                        goto found;
 
+               if (volume_id_probe_ddf_raid(id, off, size) == 0)
+                       goto found;
+
                if (volume_id_probe_intel_software_raid(id, off, size) == 0)
                        goto found;
 
index 5c1a82e1d37afe6c515ca88dfb2c01267dc79d51..9eac8273c88107e59d66c6bf034c114b3772c447 100644 (file)
@@ -56,7 +56,7 @@ int volume_id_probe_xfs(struct volume_id *id, uint64_t off, uint64_t size)
 
        volume_id_set_label_raw(id, xs->fname, 12);
        volume_id_set_label_string(id, xs->fname, 12);
-       volume_id_set_uuid(id, xs->uuid, UUID_DCE);
+       volume_id_set_uuid(id, xs->uuid, 0, UUID_DCE);
 
        volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
        id->type = "xfs";