chiark / gitweb /
usb_id: fix switch statement for video type
[elogind.git] / extras / volume_id / lib / hfs.c
index b6d7e0290bc5cd760c2ba2893f1723d1665edc80..903378b34ed0fb8acc937ed963afde23cb052ba5 100644 (file)
@@ -1,21 +1,26 @@
 /*
  * volume_id - reads filesystem label and uuid
  *
- * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
+ * Copyright (C) 2004-2008 Kay Sievers <kay.sievers@vrfy.org>
  *
- *     This program is free software; you can redistribute it and/or modify it
- *     under the terms of the GNU General Public License as published by the
- *     Free Software Foundation version 2 of the License.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
 
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -24,7 +29,8 @@
 #include <ctype.h>
 
 #include "libvolume_id.h"
-#include "util.h"
+#include "libvolume_id-private.h"
+#include "md5.h"
 
 struct hfs_finder_info{
        uint32_t        boot_folder;
@@ -139,8 +145,7 @@ static struct hfsplus_vol_header {
 
 static void hfsid_set_uuid(struct volume_id *id, const uint8_t *hfs_id)
 {
-#if 0
-       MD5_CTX md5c;
+       struct md5_ctx md5c;
        static const uint8_t hash_init[16] = {
                0xb3, 0xe2, 0x0f, 0x39, 0xf2, 0x92, 0x11, 0xd6,
                0x97, 0xa4, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac
@@ -150,17 +155,14 @@ static void hfsid_set_uuid(struct volume_id *id, const uint8_t *hfs_id)
        if (*((uint64_t *)hfs_id) == 0)
                return;
 
-       MD5_Init(&md5c);
-       MD5_Update(&md5c, &hash_init, 16);
-       MD5_Update(&md5c, hfs_id, 8);
-       MD5_Final(uuid, &md5c);
+       md5_init(&md5c);
+       md5_update(&md5c, hash_init, 16);
+       md5_update(&md5c, hfs_id, 8);
+       md5_final(&md5c, uuid);
 
        uuid[6] = 0x30 | (uuid[6] & 0x0f);
        uuid[8] = 0x80 | (uuid[8] & 0x3f);
-       volume_id_set_uuid(id, uuid, UUID_DCE);
-#endif
-
-       volume_id_set_uuid(id, hfs_id, 0, UUID_64BIT_BE);
+       volume_id_set_uuid(id, uuid, 0, UUID_DCE);
 }
 
 int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off, uint64_t size)
@@ -186,7 +188,7 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off, uint64_t siz
        struct hfsplus_extent extents[HFSPLUS_EXTENT_COUNT];
        const uint8_t *buf;
 
-       info("probing at offset 0x%llx\n", (unsigned long long) off);
+       info("probing at offset 0x%" PRIx64 "\n", off);
 
        buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200);
        if (buf == NULL)
@@ -209,7 +211,7 @@ int volume_id_probe_hfs_hfsplus(struct volume_id *id, uint64_t off, uint64_t siz
 
                off += (alloc_first_block * 512) +
                       (embed_first_block * alloc_block_size);
-               dbg("hfs wrapped hfs+ found at offset 0x%llx\n", (unsigned long long) off);
+               dbg("hfs wrapped hfs+ found at offset 0x%" PRIx64 "\n", off);
 
                buf = volume_id_get_buffer(id, off + HFS_SUPERBLOCK_OFFSET, 0x200);
                if (buf == NULL)