Lines Matching refs:partition

39 // Count of free sectors after Partition Table Sector (at logical partition).
43 // size of logical partition header in blocks
50 typedef void (*fc_get_sibling_partitions)(partition_data* partition,
55 typedef int32 (*fc_fill_partitionable_spaces_buffer)(partition_data* partition,
59 status_t pm_get_partitionable_spaces(partition_data* partition,
61 status_t ep_get_partitionable_spaces(partition_data* partition,
70 pm_get_supported_operations(partition_data* partition, uint32 mask)
79 if (partition->child_count < 4
81 && pm_get_partitionable_spaces(partition, NULL, 0, &countSpaces)
93 pm_get_supported_child_operations(partition_data* partition,
105 pm_is_sub_system_for(partition_data* partition)
107 // primary partition map doesn't naturally live in any other child partition
112 get_partition_from_offset_ep(partition_data* partition, off_t offset,
115 for (int32 i = 0; i < partition->child_count; i++) {
116 partition_data* sibling = get_child_partition(partition->id, i);
148 validate_resize(partition_data* partition, off_t* size)
152 if (newSize == partition->size)
158 newSize = sector_align(newSize, partition->block_size);
160 // grow partition?
161 if (newSize > partition->size) {
166 // shrink partition
167 // no child has to be over the new size of the parent partition
170 off_t currentEnd = partition->offset + newSize;
171 for (int32 i = 0; i < partition->child_count; i++) {
172 partition_data* child = get_child_partition(partition->id, i);
176 newSize = currentEnd - partition->offset;
178 newSize = sector_align_up(newSize, partition->block_size);
186 pm_validate_resize(partition_data* partition, off_t* size)
190 if (!partition || !size)
193 return validate_resize(partition, size);
201 partition - Intel Partition Map
204 get_sibling_partitions_pm(partition_data* partition,
212 for (int32 i = 0; i < partition->child_count; i++) {
213 partition_data* sibling = get_child_partition(partition->id, i);
242 partition - Intel Extended Partition
245 get_sibling_partitions_ep(partition_data* partition,
253 for (int32 i = 0; i < partition->child_count; i++) {
254 partition_data* sibling = get_child_partition(partition->id, i);
281 validate_resize_child(partition_data* partition, partition_data* child,
288 // shrink partition?
293 *size = sector_align(*size, partition->block_size);
296 // grow partition
297 // child must completely lie within the parent partition
298 if (childOffset + *size > partition->offset + partition->size)
299 *size = partition->offset + partition->size - childOffset;
307 getSiblingPartitions(partition, child, childOffset, &previousSibling,
312 *size = sector_align(*size, partition->block_size);
319 pm_validate_resize_child(partition_data* partition, partition_data* child,
324 if (!partition || !child || !size)
327 return validate_resize_child(partition, child, child->offset,
334 pm_validate_move(partition_data* partition, off_t* start)
338 if (!partition || !start)
347 validate_move_child(partition_data* partition, partition_data* child,
355 else if (start + childSize > partition->size)
356 start = partition->size - childSize;
358 start = sector_align(start, partition->block_size);
365 getSiblingPartitions(partition, child, childOffset, &previousSibling,
368 // we cannot move child over sibling partition
373 start = sector_align_up(start, partition->block_size);
379 start = sector_align(start, partition->block_size);
389 pm_validate_move_child(partition_data* partition, partition_data* child,
394 if (!partition || !child || !start)
399 return validate_move_child(partition, child, child->offset,
405 type has to be known, only one extended partition is allowed
406 partition - intel partition map
410 is_type_valid_pm(const char* type, partition_data* partition,
419 // only one extended partition is allowed
421 PartitionMap* map = (PartitionMap*)partition->content_cookie;
424 for (int32 i = 0; i < partition->child_count; i++) {
436 pm_validate_set_type(partition_data* partition, const char* type)
440 if (!partition || !type)
443 partition_data* parent = get_parent_partition(partition->id);
446 PrimaryPartition* child = (PrimaryPartition*)partition->cookie;
456 pm_validate_initialize(partition_data* partition, char* name,
461 if (!partition || !(pm_get_supported_operations(partition)
478 validate_create_child_partition(partition_data* partition, off_t* start,
482 *start = sector_align(*start, partition->block_size);
486 *size = sector_align(*size, partition->block_size);
488 // child must completely lie within the parent partition
489 if (*start >= partition->offset + partition->size)
491 if (*start + *size > partition->offset + partition->size)
492 *size = partition->offset + partition->size - *start;
500 getSiblingPartitions(partition, NULL, *start, &previousSibling,
503 // position check of the new partition
506 *start = sector_align_up(*start, partition->block_size);
511 *size = sector_align(*size, partition->block_size);
521 index - returns position of the new partition (first free record in MBR)
524 pm_validate_create_child(partition_data* partition, off_t* start, off_t* size,
529 if (!partition || !(pm_get_supported_operations(partition)
538 if (!is_type_valid_pm(type, partition))
541 // finding out index of the new partition (first free record in MBR)
543 PartitionMap* map = (PartitionMap*)partition->content_cookie;
559 if (*start < partition->offset + MBR_OFFSET * partition->block_size) {
560 *start = partition->offset + MBR_OFFSET * partition->block_size;
561 *start = sector_align_up(*start, partition->block_size);
564 return validate_create_child_partition(partition, start, size,
588 returns partition count
591 fill_partitionable_spaces_buffer_pm(partition_data* partition,
595 for (int32 i = 0; i < partition->child_count; i++) {
596 const partition_data* child = get_child_partition(partition->id, i);
610 returns partition count
613 fill_partitionable_spaces_buffer_ep(partition_data* partition,
617 for (int32 i = 0; i < partition->child_count; i++) {
618 const partition_data* child = get_child_partition(partition->id, i);
631 get_partitionable_spaces(partition_data* partition,
637 = new(nothrow) PartitionPosition[partition->child_count];
641 int32 partition_count = fillBuffer(partition, positions);
652 offset = sector_align_up(offset, partition->block_size);
656 size = sector_align(size, partition->block_size);
665 offset = sector_align_up(offset, partition->block_size);
667 // space in the end of partition
668 size = partition->offset + partition->size - offset;
669 size = sector_align(size, partition->block_size);
695 pm_get_partitionable_spaces(partition_data* partition,
700 if (!partition || !partition->content_type
701 || strcmp(partition->content_type, kPartitionTypeIntel)
708 return get_partitionable_spaces(partition, buffer, count, actualCount,
709 fill_partitionable_spaces_buffer_pm, MBR_OFFSET * partition->block_size,
716 pm_get_next_supported_type(partition_data* partition, int32* cookie,
721 if (!partition || !partition->content_type
722 || strcmp(partition->content_type, kPartitionTypeIntel)
753 pm_shadow_changed(partition_data* partition, partition_data* child,
756 TRACE(("intel: pm_shadow_changed(%p, %p, %" B_PRIu32 ")\n", partition,
762 // get the physical partition
764 partition->id);
767 "physical partition with ID %" B_PRId32 "\n",
768 partition->id);
775 "content cookie, physical partition: %" B_PRId32 "\n",
776 partition->id);
791 partition->content_cookie = map;
798 // get the physical child partition
802 "no physical partition with ID %" B_PRId32 "\n", child->id);
808 "no cookie, physical partition: %" B_PRId32 "\n",
813 // primary partition index
816 if (!partition->content_cookie) {
818 "no content cookie, physical partition: %" B_PRId32 "\n",
819 partition->id);
823 // get the primary partition
825 = ((PartitionMapCookie*)partition->content_cookie);
830 "partition %" B_PRId32 " is empty, primary index: "
842 // create an empty partition map
847 partition->content_cookie = map;
854 if (!partition->content_cookie) {
856 "no content cookie, partition: %" B_PRId32 "\n",
857 partition->id);
862 = ((PartitionMapCookie*)partition->content_cookie);
864 // find an empty primary partition slot
875 "no empty primary slot, partition: %" B_PRId32 "\n",
876 partition->id);
885 "invalid partition type, partition: %" B_PRId32 "\n",
886 partition->id);
934 // get out partition
935 partition_data* partition = get_partition(partitionID);
936 if (!partition)
942 if (!pm_validate_resize(partition, &validatedSize))
948 // TODO: partition->size is not supposed to be touched.
949 partition->size = validatedSize;
950 partition->content_size = validatedSize;
972 // get out partition, child and partition map structure
973 partition_data* partition = get_parent_partition(partitionID);
975 if (!partition || !child)
977 PartitionMap* map = (PartitionMap*)partition->content_cookie;
985 if (!pm_validate_resize_child(partition, child, &validatedSize))
994 // TODO: The partition is not supposed to be locked here!
1028 // get out partition
1029 partition_data* partition = get_partition(partitionID);
1030 if (!partition)
1034 if (!pm_validate_move(partition, &offset))
1131 // get partition, child and partition map structure
1132 partition_data* partition = get_partition(partitionID);
1134 if (!partition || !child)
1136 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1143 if (!pm_validate_move_child(partition, child, &validatedOffset))
1152 uint8* buffer = allocate_buffer(partition->block_size, MAX_MOVE_BUFFER,
1157 // partition moving
1158 // TODO: The partition is not supposed to be locked at this point!
1162 buffer, allocated * partition->block_size, job);
1167 // partition moved
1172 PartitionMapWriter writer(fd, partition->block_size);
1176 // something went wrong - this is fatal (partition has been moved)
1200 // get parent partition, child and partition map structure
1201 partition_data* partition = get_parent_partition(partitionID);
1203 if (!partition || !child)
1205 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1225 // setting type to the partition
1230 // TODO: The partition is not supposed to be locked at this point!
1270 // get parent partition, child and partition map structure
1271 partition_data* partition = get_parent_partition(partitionID);
1273 if (partition == NULL || child == NULL)
1275 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1299 PrimaryPartition* partition = map->PrimaryPartitionAt(i);
1300 partition->SetActive(false);
1307 // TODO: The partition is not supposed to be locked at this point!
1340 // get partition and partition map structure
1341 partition_data* partition = get_partition(partitionID);
1342 if (!partition)
1346 // we will write an empty partition map
1350 PartitionMapWriter writer(fd, partition->block_size);
1356 // rescan partition
1376 // We overwrite the first block, which contains the partition table.
1412 // get partition and partition map structure
1413 partition_data* partition = get_partition(partitionID);
1414 if (!partition)
1416 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1420 // validate the offset, size and get index of the new partition
1426 if (!pm_validate_create_child(partition, &validatedOffset, &validatedSize,
1431 // finding out free primary partition in the map (index from
1437 // creating partition
1439 partition_data* child = create_child_partition(partition->id, index,
1458 PrimaryPartition* partition = map->PrimaryPartitionAt(i);
1459 partition->SetActive(false);
1472 // TODO: The partition is not supposed to be locked at this point!
1493 // rescan partition if needed
1522 partition_data* partition = get_partition(partitionID);
1524 if (!partition || !child)
1527 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1541 // TODO: The partition is not supposed to be locked at this point!
1558 ep_get_supported_operations(partition_data* partition, uint32 mask)
1565 if (partition_data* parent = get_parent_partition(partition->id)) {
1566 if (partition->type
1567 && strcmp(partition->type, kPartitionTypeIntelExtended) == 0
1575 if (ep_get_partitionable_spaces(partition, NULL, 0, &countSpaces)
1587 ep_get_supported_child_operations(partition_data* partition,
1599 ep_is_sub_system_for(partition_data* partition)
1601 if (partition == NULL)
1605 "%" B_PRId64 ", %" B_PRId32 ", %s)\n", partition->id, partition->offset,
1606 partition->size, partition->block_size, partition->content_type));
1608 // Intel Extended Partition can live in child partition of Intel Partition
1610 return partition->content_type
1611 && !strcmp(partition->content_type, kPartitionTypeIntel);
1620 ep_validate_resize(partition_data* partition, off_t* size)
1624 if (!partition || !size)
1627 return validate_resize(partition, size);
1633 ep_validate_resize_child(partition_data* partition, partition_data* child,
1638 if (!partition || !child || !_size)
1643 if (!validate_resize_child(partition, child, child->offset,
1653 ep_validate_move(partition_data* partition, off_t* start)
1657 if (!partition || !start)
1666 ep_validate_move_child(partition_data* partition, partition_data* child,
1671 if (!partition || !child || !_start)
1678 if (!validate_move_child(partition, child, child->offset,
1699 ep_validate_set_type(partition_data* partition, const char* type)
1703 if (!partition || !type)
1713 ep_validate_initialize(partition_data* partition, char* name,
1718 if (!partition || !(ep_get_supported_operations(partition)
1731 ep_validate_create_child(partition_data* partition, off_t* offset, off_t* size,
1733 // index - returns position of the new partition (the last one)
1741 ep_get_partitionable_spaces(partition_data* partition,
1746 if (!partition || !partition->content_type
1747 || strcmp(partition->content_type, kPartitionTypeIntelExtended)
1754 return get_partitionable_spaces(partition, buffer, count, actualCount,
1756 partition->offset + PTS_OFFSET * partition->block_size,
1757 PTS_OFFSET * partition->block_size,
1758 PTS_OFFSET * partition->block_size);
1764 ep_get_next_supported_type(partition_data* partition, int32* cookie,
1769 if (!partition || !partition->content_type
1770 || strcmp(partition->content_type, kPartitionTypeIntelExtended)
1805 ep_shadow_changed(partition_data* partition, partition_data* child,
1810 if (!partition)
1819 check_partition_location_ep(partition_data* partition, off_t offset,
1822 if (!partition)
1826 off_t alignedOffset = sector_align(offset, partition->block_size);
1830 // partition does not lie within extended partition
1831 if (offset < partition->offset
1832 || (offset > partition->offset + partition->size
1833 && offset + size <= partition->offset + partition->size))
1836 // check if the new partition table is within an existing partition
1837 // or that the new partition does not overwrite an existing partition
1839 for (int32 i = 0; i < partition->child_count; i++) {
1840 partition_data* sibling = get_child_partition(partition->id, i);
1873 // get out partition
1874 partition_data* partition = get_partition(partitionID);
1875 if (!partition)
1881 if (!ep_validate_resize(partition, &validatedSize))
1887 // TODO: partition->size is not supposed to be touched.
1888 partition->size = validatedSize;
1889 partition->content_size = validatedSize;
1911 // get out partition, child and LogicalPartition structure
1912 partition_data* partition = get_parent_partition(partitionID);
1914 if (!partition || !child)
1917 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
1924 if (!ep_validate_resize_child(partition, child, &validatedSize))
1933 PartitionMapWriter writer(fd, partition->block_size);
1934 // TODO: The partition is not supposed to be locked here!
1970 // get out partition
1971 partition_data* partition = get_partition(partitionID);
1972 if (!partition)
1977 if (!ep_validate_move(partition, &offset))
1999 // get partition, child and LogicalPartition structure
2000 partition_data* partition = get_partition(partitionID);
2002 if (!partition || !child)
2005 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2011 if (!ep_validate_move_child(partition, child, &validatedOffset))
2022 uint8* buffer = allocate_buffer(partition->block_size, MAX_MOVE_BUFFER,
2027 // partition moving
2030 // move partition with its header (partition table)
2034 allocated * partition->block_size, job);
2039 // partition moved
2045 PartitionMapWriter writer(fd, partition->block_size);
2046 // TODO: If partition->offset is > prev->offset, then writing
2047 // the previous logical partition table will fail!
2048 // TODO: The partition is not supposed to be locked here!
2051 // something went wrong - this is fatal (partition has been moved)
2081 // get partition, child and LogicalPartition structure
2082 partition_data* partition = get_parent_partition(partitionID);
2084 if (!partition || !child)
2087 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2105 // setting type to the partition
2110 PartitionMapWriter writer(fd, partition->block_size);
2111 // TODO: The partition is not supposed to be locked here!
2145 // get partition
2146 partition_data* partition = get_partition(partitionID);
2147 if (!partition)
2150 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2156 if (!ep_validate_initialize(partition, NULL, parameters))
2159 // partition init (we have no child partition)
2162 partition->status = B_PARTITION_VALID;
2163 partition->flags |= B_PARTITION_PARTITIONING_SYSTEM;
2164 partition->content_size = partition->size;
2167 partition->content_cookie = primary;
2173 PartitionMapWriter writer(fd, partition->block_size);
2174 // TODO: The partition is not supposed to be locked here!
2206 // get partition data
2207 partition_data* partition = get_partition(partitionID);
2209 if (partition == NULL || parent == NULL)
2212 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2234 // check the partition location
2235 if (!check_partition_location_ep(partition, offset, size, ptsOffset))
2238 // creating partition
2240 partition_data* child = create_child_partition(partition->id,
2241 partition->child_count, offset, size, *childID);
2245 // setup logical partition
2258 logical->SetBlockSize(partition->block_size);
2271 // Write the logical partition's EBR first in case of failure.
2272 // This way we will not add a partition to the previous logical
2273 // partition. If there is no previous logical partition then write
2274 // the current partition's EBR to the first sector of the primary partition
2322 partition_data* partition = get_partition(partitionID);
2325 if (partition == NULL || parent == NULL || child == NULL)
2328 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2361 if (get_partition_from_offset_ep(partition, next->Offset(),