hfs.c revision 2603474ff9be2418900581da1af5cccc9f13cae1
/*
* volume_id - reads filesystem label and uuid
*
* Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
*
* under the terms of the GNU General Public License as published by the
* Free Software Foundation version 2 of the License.
*/
#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>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include "libvolume_id.h"
#include "libvolume_id-private.h"
#include "util.h"
struct hfs_finder_info{
} PACKED;
static struct hfs_mdb {
struct hfs_finder_info finder_info;
struct hfsplus_bnode_descriptor {
} PACKED;
struct hfsplus_bheader_record {
} PACKED;
struct hfsplus_catalog_key {
} PACKED;
struct hfsplus_extent {
} PACKED;
#define HFSPLUS_EXTENT_COUNT 8
struct hfsplus_fork {
} PACKED;
static struct hfsplus_vol_header {
struct hfs_finder_info finder_info;
struct hfsplus_fork alloc_file;
struct hfsplus_fork ext_file;
struct hfsplus_fork cat_file;
struct hfsplus_fork attr_file;
struct hfsplus_fork start_file;
#define HFS_SUPERBLOCK_OFFSET 0x400
#define HFS_NODE_LEAF 0xff
#define HFSPLUS_POR_CNID 1
{
#if 0
0xb3, 0xe2, 0x0f, 0x39, 0xf2, 0x92, 0x11, 0xd6,
0x97, 0xa4, 0x00, 0x30, 0x65, 0x43, 0xec, 0xac
};
return;
#endif
}
{
unsigned int blocksize;
unsigned int cat_block;
unsigned int ext_block_start;
unsigned int ext_block_count;
int ext;
unsigned int leaf_node_head;
unsigned int leaf_node_count;
unsigned int leaf_node_size;
unsigned int leaf_block;
unsigned int alloc_block_size;
unsigned int alloc_first_block;
unsigned int embed_first_block;
unsigned int record_count;
struct hfsplus_bnode_descriptor *descr;
struct hfsplus_bheader_record *bnode;
struct hfsplus_catalog_key *key;
unsigned int label_len;
return -1;
goto checkplus;
/* it may be just a hfs wrapper for hfs+ */
return -1;
goto checkplus;
}
}
return 0;
goto hfsplus;
goto hfsplus;
return -1;
goto found;
bnode = (struct hfsplus_bheader_record *)
&buf[sizeof(struct hfsplus_bnode_descriptor)];
if (leaf_node_count == 0)
goto found;
/* get physical location */
if (ext_block_count == 0)
goto found;
/* this is our extent */
if (leaf_block < ext_block_count)
break;
}
if (ext == HFSPLUS_EXTENT_COUNT)
goto found;
goto found;
if (record_count == 0)
goto found;
goto found;
key = (struct hfsplus_catalog_key *)
&buf[sizeof(struct hfsplus_bnode_descriptor)];
goto found;
return 0;
}