write out the backup header too

Now that we actually have the real backup header, we can safely write it
out without having the wrong LBA pointers and other such issues that
would come from writing the primary header to the backup header (ask me
how I know)
main
Caleb Connolly 1 year ago
parent 7a5d5ee40e
commit 7f852512b6
No known key found for this signature in database
GPG Key ID: 0583312B195F64B6
  1. 15
      gpt-utils.cpp

@ -774,6 +774,21 @@ int gpt_disk_commit(struct gpt_disk *disk)
__func__); __func__);
goto error; goto error;
} }
// Write the backup header
if (gpt_set_header(disk->hdr_bak, fd, SECONDARY_GPT) != 0) {
fprintf(stderr, "%s: Failed to update backup GPT header\n",
__func__);
goto error;
}
LOGD("%s: Writing back backup partition array\n", __func__);
// Write back the backup partition array
if (gpt_set_pentry_arr(disk->hdr_bak, fd, disk->pentry_arr_bak)) {
fprintf(stderr,
"%s: Failed to write backup GPT partition arr\n",
__func__);
goto error;
}
fsync(fd); fsync(fd);
close(fd); close(fd);
return 0; return 0;

Loading…
Cancel
Save