Lines Matching +full:partition +full:- +full:block_size

2  * Copyright 2003-2009, Haiku, Inc. All Rights Reserved.
6 * Ingo Weinhold, bonefish@cs.tu-berlin.de
15 // TODO: The implementation is very strict right now. It rejects a partition
16 // completely, if it finds an error in its partition tables. We should see,
17 // what error can be handled gracefully, e.g. by ignoring the partition
18 // descriptor or the whole partition table sector.
81 // #pragma mark - Intel Partition Map Module
100 pm_identify_partition(int fd, partition_data* partition, void** cookie)
103 if (fd < 0 || !partition || !cookie)
104 return -1;
107 "%" B_PRId64 ", %" B_PRId32 ")\n", fd, partition->id, partition->offset,
108 partition->size, partition->block_size));
110 if (partition->type
111 && !strcmp(partition->type, kPartitionTypeIntelExtended)) {
112 return -1;
118 return -1;
120 // read the partition structure
121 PartitionMapParser parser(fd, 0, partition->size, partition->block_size);
126 return -1;
134 bool hasChildren = (map->CountNonEmptyPartitions() > 0);
135 bool hasParent = (get_parent_partition(partition->id) != NULL);
143 // No children -- might be a freshly initialized disk. But it could
148 // NOTE: It seems supporting nested partition maps makes more trouble than it
156 // else claims the partition, we take it anyway.
159 return -1;
165 pm_scan_partition(int fd, partition_data* partition, void* cookie)
168 if (fd < 0 || !partition || !cookie)
172 "%" B_PRId64 ", %" B_PRId32 ")\n", fd, partition->id, partition->offset,
173 partition->size, partition->block_size));
177 partition->status = B_PARTITION_VALID;
178 partition->flags |= B_PARTITION_PARTITIONING_SYSTEM;
179 partition->content_size = partition->size;
183 partition->content_cookie = map;
188 PrimaryPartition* primary = map->PrimaryPartitionAt(i);
189 if (!primary->IsEmpty()) {
190 partition_data* child = create_child_partition(partition->id,
191 index, partition->offset + primary->Offset(), primary->Size(),
192 -1);
200 child->block_size = partition->block_size;
204 primary->GetTypeString(type);
205 child->type = strdup(type);
208 sprintf(buffer, "type = %u ; active = %d", primary->Type(),
209 primary->Active());
210 child->parameters = strdup(buffer);
211 child->cookie = primary;
213 if (!child->type || !child->parameters) {
222 atomic_add(&map->ref_count, 1);
224 partition->content_cookie = NULL;
225 for (int32 i = 0; i < partition->child_count; i++) {
226 if (partition_data* child = get_child_partition(partition->id, i))
227 child->cookie = NULL;
237 pm_free_identify_partition_cookie(partition_data*/* partition*/, void* cookie)
241 if (atomic_add(&map->ref_count, -1) == 1)
249 pm_free_partition_cookie(partition_data* partition)
252 // by the partition containing the partition map
253 if (partition)
254 partition->cookie = NULL;
260 pm_free_partition_content_cookie(partition_data* partition)
262 if (partition && partition->content_cookie) {
263 pm_free_identify_partition_cookie(partition, partition->content_cookie);
264 partition->content_cookie = NULL;
269 // #pragma mark - Intel Extended Partition Module
288 ep_identify_partition(int fd, partition_data* partition, void** cookie)
291 if (fd < 0 || !partition || !cookie || !partition->cookie)
292 return -1;
295 "%" B_PRId32 ")\n", fd, partition->offset, partition->size,
296 partition->block_size));
298 // our parent must be a intel partition map partition and we must have
299 // extended partition type
300 if (!partition->type
301 || strcmp(partition->type, kPartitionTypeIntelExtended)) {
302 return -1;
304 partition_data* parent = get_parent_partition(partition->id);
305 if (!parent || !parent->content_type
306 || strcmp(parent->content_type, kPartitionTypeIntel)) {
307 return -1;
317 ep_scan_partition(int fd, partition_data* partition, void* cookie)
320 if (fd < 0 || !partition || !partition->cookie)
324 "%" B_PRId32 ")\n", fd, partition->offset, partition->size,
325 partition->block_size));
327 partition_data* parent = get_parent_partition(partition->id);
331 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
333 partition->status = B_PARTITION_VALID;
334 partition->flags |= B_PARTITION_PARTITIONING_SYSTEM;
335 partition->content_size = partition->size;
339 partition->content_cookie = primary;
343 for (int32 i = 0; i < primary->CountLogicalPartitions(); i++) {
344 LogicalPartition* logical = primary->LogicalPartitionAt(i);
345 partition_data* child = create_child_partition(partition->id, index,
346 parent->offset + logical->Offset(), logical->Size(), -1);
351 "partition\n"));
355 child->block_size = partition->block_size;
359 logical->GetTypeString(type);
360 child->type = strdup(type);
365 logical->Active() ? "true" : "false",
366 logical->PartitionTableOffset());
367 child->parameters = strdup(buffer);
368 child->cookie = logical;
370 if (!child->type || !child->parameters) {
380 partition->content_cookie = NULL;
381 for (int32 i = 0; i < partition->child_count; i++) {
382 if (partition_data* child = get_child_partition(partition->id, i))
383 child->cookie = NULL;
392 ep_free_identify_partition_cookie(partition_data* partition, void* cookie)
400 ep_free_partition_cookie(partition_data* partition)
402 // the logical partition's cookie belongs to the partition map partition
403 if (partition)
404 partition->cookie = NULL;
410 ep_free_partition_content_cookie(partition_data* partition)
412 // the extended partition's cookie belongs to the partition map partition
413 if (partition)
414 partition->content_cookie = NULL;
418 // #pragma mark - modules
485 // shadow partition modification
573 // shadow partition modification