aboutsummaryrefslogtreecommitdiff
path: root/util-linux/volume_id/hfs.c
diff options
context:
space:
mode:
authorSven-Göran Bergh <sgb@systemasis.org>2013-01-14 00:37:00 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2013-01-14 00:37:00 +0100
commit07b419dbcb34958d0f6050231783bd78f7d0344f (patch)
treef3488ec84172a9e69b3ffb2e9e4cecf0b8854e6f /util-linux/volume_id/hfs.c
parenta58f7b7d2f73b84638a8e8c14a142d4a03678eeb (diff)
downloadbusybox-w32-07b419dbcb34958d0f6050231783bd78f7d0344f.tar.gz
busybox-w32-07b419dbcb34958d0f6050231783bd78f7d0344f.tar.bz2
busybox-w32-07b419dbcb34958d0f6050231783bd78f7d0344f.zip
volume_id: display hfs[+] 128-bit UUID properly
Signed-off-by: Sven-Göran Bergh <sgb@systemasis.org> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/volume_id/hfs.c')
-rw-r--r--util-linux/volume_id/hfs.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/util-linux/volume_id/hfs.c b/util-linux/volume_id/hfs.c
index dd5ec2415..3d9704d12 100644
--- a/util-linux/volume_id/hfs.c
+++ b/util-linux/volume_id/hfs.c
@@ -131,6 +131,27 @@ struct hfsplus_vol_header {
131#define HFS_NODE_LEAF 0xff 131#define HFS_NODE_LEAF 0xff
132#define HFSPLUS_POR_CNID 1 132#define HFSPLUS_POR_CNID 1
133 133
134static void FAST_FUNC hfs_set_uuid(struct volume_id *id, const uint8_t *hfs_id)
135{
136#define hfs_id_len 8
137 md5_ctx_t md5c;
138 uint8_t uuid[16];
139 unsigned i;
140
141 for (i = 0; i < hfs_id_len; i++)
142 if (hfs_id[i] != 0)
143 goto do_md5;
144 return;
145 do_md5:
146 md5_begin(&md5c);
147 md5_hash(&md5c, "\263\342\17\71\362\222\21\326\227\244\0\60\145\103\354\254", 16);
148 md5_hash(&md5c, hfs_id, hfs_id_len);
149 md5_end(&md5c, uuid);
150 uuid[6] = 0x30 | (uuid[6] & 0x0f);
151 uuid[8] = 0x80 | (uuid[8] & 0x3f);
152 volume_id_set_uuid(id, uuid, UUID_DCE);
153}
154
134int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/) 155int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/)
135{ 156{
136 uint64_t off = 0; 157 uint64_t off = 0;
@@ -193,7 +214,7 @@ int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/
193 volume_id_set_label_string(id, hfs->label, hfs->label_len) ; 214 volume_id_set_label_string(id, hfs->label, hfs->label_len) ;
194 } 215 }
195 216
196 volume_id_set_uuid(id, hfs->finder_info.id, UUID_HFS); 217 hfs_set_uuid(id, hfs->finder_info.id);
197// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM); 218// volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
198 IF_FEATURE_BLKID_TYPE(id->type = "hfs";) 219 IF_FEATURE_BLKID_TYPE(id->type = "hfs";)
199 220
@@ -207,7 +228,7 @@ int FAST_FUNC volume_id_probe_hfs_hfsplus(struct volume_id *id /*,uint64_t off*/
207 return -1; 228 return -1;
208 229
209 hfsplus: 230 hfsplus:
210 volume_id_set_uuid(id, hfsplus->finder_info.id, UUID_HFS); 231 hfs_set_uuid(id, hfsplus->finder_info.id);
211 232
212 blocksize = be32_to_cpu(hfsplus->blocksize); 233 blocksize = be32_to_cpu(hfsplus->blocksize);
213 dbg("blocksize %u", blocksize); 234 dbg("blocksize %u", blocksize);