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!
1266 // get partition and partition map structure
1267 partition_data* partition = get_partition(partitionID);
1268 if (!partition)
1272 // we will write an empty partition map
1276 PartitionMapWriter writer(fd, partition->block_size);
1282 // rescan partition
1302 // We overwrite the first block, which contains the partition table.
1338 // get partition and partition map structure
1339 partition_data* partition = get_partition(partitionID);
1340 if (!partition)
1342 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1346 // validate the offset, size and get index of the new partition
1352 if (!pm_validate_create_child(partition, &validatedOffset, &validatedSize,
1357 // finding out free primary partition in the map (index from
1363 // creating partition
1365 partition_data* child = create_child_partition(partition->id, index,
1384 PrimaryPartition* partition = map->PrimaryPartitionAt(i);
1385 partition->SetActive(false);
1398 // TODO: The partition is not supposed to be locked at this point!
1419 // rescan partition if needed
1448 partition_data* partition = get_partition(partitionID);
1450 if (!partition || !child)
1453 PartitionMap* map = (PartitionMap*)partition->content_cookie;
1467 // TODO: The partition is not supposed to be locked at this point!
1484 ep_get_supported_operations(partition_data* partition, uint32 mask)
1491 if (partition_data* parent = get_parent_partition(partition->id)) {
1492 if (partition->type
1493 && strcmp(partition->type, kPartitionTypeIntelExtended) == 0
1501 if (ep_get_partitionable_spaces(partition, NULL, 0, &countSpaces)
1513 ep_get_supported_child_operations(partition_data* partition,
1525 ep_is_sub_system_for(partition_data* partition)
1527 if (partition == NULL)
1531 "%" B_PRId64 ", %" B_PRId32 ", %s)\n", partition->id, partition->offset,
1532 partition->size, partition->block_size, partition->content_type));
1534 // Intel Extended Partition can live in child partition of Intel Partition
1536 return partition->content_type
1537 && !strcmp(partition->content_type, kPartitionTypeIntel);
1546 ep_validate_resize(partition_data* partition, off_t* size)
1550 if (!partition || !size)
1553 return validate_resize(partition, size);
1559 ep_validate_resize_child(partition_data* partition, partition_data* child,
1564 if (!partition || !child || !_size)
1569 if (!validate_resize_child(partition, child, child->offset,
1579 ep_validate_move(partition_data* partition, off_t* start)
1583 if (!partition || !start)
1592 ep_validate_move_child(partition_data* partition, partition_data* child,
1597 if (!partition || !child || !_start)
1604 if (!validate_move_child(partition, child, child->offset,
1625 ep_validate_set_type(partition_data* partition, const char* type)
1629 if (!partition || !type)
1639 ep_validate_initialize(partition_data* partition, char* name,
1644 if (!partition || !(ep_get_supported_operations(partition)
1657 ep_validate_create_child(partition_data* partition, off_t* offset, off_t* size,
1659 // index - returns position of the new partition (the last one)
1667 ep_get_partitionable_spaces(partition_data* partition,
1672 if (!partition || !partition->content_type
1673 || strcmp(partition->content_type, kPartitionTypeIntelExtended)
1680 return get_partitionable_spaces(partition, buffer, count, actualCount,
1682 partition->offset + PTS_OFFSET * partition->block_size,
1683 PTS_OFFSET * partition->block_size,
1684 PTS_OFFSET * partition->block_size);
1690 ep_get_next_supported_type(partition_data* partition, int32* cookie,
1695 if (!partition || !partition->content_type
1696 || strcmp(partition->content_type, kPartitionTypeIntelExtended)
1731 ep_shadow_changed(partition_data* partition, partition_data* child,
1736 if (!partition)
1745 check_partition_location_ep(partition_data* partition, off_t offset,
1748 if (!partition)
1752 off_t alignedOffset = sector_align(offset, partition->block_size);
1756 // partition does not lie within extended partition
1757 if (offset < partition->offset
1758 || (offset > partition->offset + partition->size
1759 && offset + size <= partition->offset + partition->size))
1762 // check if the new partition table is within an existing partition
1763 // or that the new partition does not overwrite an existing partition
1765 for (int32 i = 0; i < partition->child_count; i++) {
1766 partition_data* sibling = get_child_partition(partition->id, i);
1799 // get out partition
1800 partition_data* partition = get_partition(partitionID);
1801 if (!partition)
1807 if (!ep_validate_resize(partition, &validatedSize))
1813 // TODO: partition->size is not supposed to be touched.
1814 partition->size = validatedSize;
1815 partition->content_size = validatedSize;
1837 // get out partition, child and LogicalPartition structure
1838 partition_data* partition = get_parent_partition(partitionID);
1840 if (!partition || !child)
1843 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
1850 if (!ep_validate_resize_child(partition, child, &validatedSize))
1859 PartitionMapWriter writer(fd, partition->block_size);
1860 // TODO: The partition is not supposed to be locked here!
1896 // get out partition
1897 partition_data* partition = get_partition(partitionID);
1898 if (!partition)
1903 if (!ep_validate_move(partition, &offset))
1925 // get partition, child and LogicalPartition structure
1926 partition_data* partition = get_partition(partitionID);
1928 if (!partition || !child)
1931 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
1937 if (!ep_validate_move_child(partition, child, &validatedOffset))
1948 uint8* buffer = allocate_buffer(partition->block_size, MAX_MOVE_BUFFER,
1953 // partition moving
1956 // move partition with its header (partition table)
1960 allocated * partition->block_size, job);
1965 // partition moved
1971 PartitionMapWriter writer(fd, partition->block_size);
1972 // TODO: If partition->offset is > prev->offset, then writing
1973 // the previous logical partition table will fail!
1974 // TODO: The partition is not supposed to be locked here!
1977 // something went wrong - this is fatal (partition has been moved)
2007 // get partition, child and LogicalPartition structure
2008 partition_data* partition = get_parent_partition(partitionID);
2010 if (!partition || !child)
2013 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2031 // setting type to the partition
2036 PartitionMapWriter writer(fd, partition->block_size);
2037 // TODO: The partition is not supposed to be locked here!
2071 // get partition
2072 partition_data* partition = get_partition(partitionID);
2073 if (!partition)
2076 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2082 if (!ep_validate_initialize(partition, NULL, parameters))
2085 // partition init (we have no child partition)
2088 partition->status = B_PARTITION_VALID;
2089 partition->flags |= B_PARTITION_PARTITIONING_SYSTEM;
2090 partition->content_size = partition->size;
2093 partition->content_cookie = primary;
2099 PartitionMapWriter writer(fd, partition->block_size);
2100 // TODO: The partition is not supposed to be locked here!
2132 // get partition data
2133 partition_data* partition = get_partition(partitionID);
2135 if (partition == NULL || parent == NULL)
2138 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2160 // check the partition location
2161 if (!check_partition_location_ep(partition, offset, size, ptsOffset))
2164 // creating partition
2166 partition_data* child = create_child_partition(partition->id,
2167 partition->child_count, offset, size, *childID);
2171 // setup logical partition
2184 logical->SetBlockSize(partition->block_size);
2197 // Write the logical partition's EBR first in case of failure.
2198 // This way we will not add a partition to the previous logical
2199 // partition. If there is no previous logical partition then write
2200 // the current partition's EBR to the first sector of the primary partition
2248 partition_data* partition = get_partition(partitionID);
2251 if (partition == NULL || parent == NULL || child == NULL)
2254 PrimaryPartition* primary = (PrimaryPartition*)partition->cookie;
2287 if (get_partition_from_offset_ep(partition, next->Offset(),