limine-install: Zero out unused partition entries

This commit is contained in:
mintsuki 2021-03-17 18:14:09 +01:00
parent e374d73265
commit f6aab27f23
1 changed files with 9 additions and 0 deletions

View File

@ -424,6 +424,15 @@ int main(int argc, char *argv[]) {
free(partition_array); free(partition_array);
// Zero out unused partitions
void *empty = calloc(1, gpt_header.size_of_partition_entry);
for (size_t i = max_partition_entry_used + 1; i < new_partition_entry_count; i++) {
device_write(empty,
gpt_header.partition_entry_lba * lb_size + i * gpt_header.size_of_partition_entry,
gpt_header.size_of_partition_entry);
}
free(empty);
gpt_header.partition_entry_array_crc32 = crc32_partition_array; gpt_header.partition_entry_array_crc32 = crc32_partition_array;
gpt_header.number_of_partition_entries = new_partition_entry_count; gpt_header.number_of_partition_entries = new_partition_entry_count;
gpt_header.crc32 = 0; gpt_header.crc32 = 0;