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:
parent
f30f09a42f
commit
58c4e79708
12
gpt.c
12
gpt.c
|
@ -362,6 +362,12 @@ int gpt_write(const struct gpt *gpt)
|
||||||
return -1;
|
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));
|
memcpy(&hdr, &gpt->header, sizeof(hdr));
|
||||||
|
|
||||||
hdr.ptbl_crc = 0;
|
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);
|
close(fd);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
Loading…
Reference in New Issue