Re-read the partition table before and after write

Note we re-read before save to ensure that the block device is not in use.
This commit is contained in:
Tom Marshall 2015-04-18 09:37:31 -07:00
parent f30f09a42f
commit 58c4e79708
1 changed files with 12 additions and 0 deletions

12
gpt.c
View File

@ -362,6 +362,12 @@ int gpt_write(const struct gpt *gpt)
return -1;
}
rc = ioctl(fd, BLKRRPART);
if (rc != 0) {
fprintf(stderr, "failed to re-read partition table\n");
return -1;
}
memcpy(&hdr, &gpt->header, sizeof(hdr));
hdr.ptbl_crc = 0;
@ -430,6 +436,12 @@ int gpt_write(const struct gpt *gpt)
}
}
rc = ioctl(fd, BLKRRPART);
if (rc != 0) {
fprintf(stderr, "failed to re-read partition table\n");
return -1;
}
close(fd);
return 0;