2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //kbuild:### lib-$(CONFIG_FEATURE_VOLUMEID_MAC) += mac.o
23 //config:### config FEATURE_VOLUMEID_MAC
24 //config:### bool "mac filesystem"
25 //config:### default y
26 //config:### depends on VOLUMEID
28 #include "volume_id_internal.h"
30 struct mac_driver_desc {
36 struct mac_partition {
46 int FAST_FUNC volume_id_probe_mac_partition_map(struct volume_id *id, uint64_t off)
49 struct mac_driver_desc *driver;
50 struct mac_partition *part;
52 dbg("probing at offset 0x%llx", (unsigned long long) off);
54 buf = volume_id_get_buffer(id, off, 0x200);
58 part = (struct mac_partition *) buf;
59 if (part->signature[0] == 'P' && part->signature[1] == 'M' /* "PM" */
60 && (memcmp(part->type, "Apple_partition_map", 19) == 0)
62 /* linux creates an own subdevice for the map
63 * just return the type if the drive header is missing */
64 // volume_id_set_usage(id, VOLUME_ID_PARTITIONTABLE);
65 // id->type = "mac_partition_map";
69 driver = (struct mac_driver_desc *) buf;
70 if (driver->signature[0] == 'E' && driver->signature[1] == 'R') { /* "ER" */
71 /* we are on a main device, like a CD
72 * just try to probe the first partition from the map */
73 unsigned bsize = be16_to_cpu(driver->block_size);
77 /* get first entry of partition table */
78 buf = volume_id_get_buffer(id, off + bsize, 0x200);
82 part = (struct mac_partition *) buf;
83 if (part->signature[0] != 'P' || part->signature[1] != 'M') /* not "PM" */
86 part_count = be32_to_cpu(part->map_count);
87 dbg("expecting %d partition entries", part_count);
89 if (id->partitions != NULL)
91 id->partitions = xzalloc(part_count * sizeof(struct volume_id_partition));
93 id->partition_count = part_count;
95 for (i = 0; i < part_count; i++) {
99 buf = volume_id_get_buffer(id, off + ((i+1) * bsize), 0x200);
103 part = (struct mac_partition *) buf;
104 if (part->signature[0] != 'P' || part->signature[1] != 'M') /* not "PM" */
107 poff = be32_to_cpu(part->start_block) * bsize;
108 plen = be32_to_cpu(part->block_count) * bsize;
109 dbg("found '%s' partition entry at 0x%llx, len 0x%llx",
110 part->type, (unsigned long long) poff,
111 (unsigned long long) plen);
113 // id->partitions[i].pt_off = poff;
114 // id->partitions[i].pt_len = plen;
116 // if (memcmp(part->type, "Apple_Free", 10) == 0) {
117 // volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_UNUSED);
118 // } else if (memcmp(part->type, "Apple_partition_map", 19) == 0) {
119 // volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_PARTITIONTABLE);
121 // volume_id_set_usage_part(&id->partitions[i], VOLUME_ID_UNPROBED);
124 // volume_id_set_usage(id, VOLUME_ID_PARTITIONTABLE);
125 // id->type = "mac_partition_map";