MCPcopy Create free account
hub / github.com/cgsecurity/testdisk / align_structure_i386

Function align_structure_i386

src/godmode.c:108–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108static void align_structure_i386(list_part_t *list_part, const disk_t *disk, const unsigned int align)
109{
110 list_part_t *element;
111 for(element=list_part; element!=NULL; element=element->next)
112 {
113 uint64_t partition_end;
114 unsigned int location_boundary;
115 const partition_t *part=element->part;
116 if(align==0)
117 location_boundary=disk->sector_size;
118 else
119 location_boundary=align_structure_aux(part->part_offset, disk);
120 partition_end=(part->part_offset+part->part_size-1+location_boundary-1)/location_boundary*location_boundary-1;
121 if(align!=0 && element->next!=NULL)
122 {
123 const partition_t *next_partition=element->next->part;
124 if( next_partition->part_offset > part->part_offset + part->part_size -1 &&
125 next_partition->part_offset <= partition_end)
126 {
127 /* Do not align the partition if it overlaps the next one because of that */
128 location_boundary=disk->sector_size;
129 partition_end=(part->part_offset + part->part_size-1+location_boundary-1)/location_boundary*location_boundary-1;
130 }
131 }
132 element->part->part_size=partition_end - part->part_offset+1;
133 }
134}
135
136static void align_structure(list_part_t *list_part, const disk_t *disk, const unsigned int align)
137{

Callers 1

align_structureFunction · 0.85

Calls 1

align_structure_auxFunction · 0.85

Tested by

no test coverage detected