Use ioctl() to get correct media size so that we can locate
ZFS labels in the tail of the media. Approved by: re (kensmith), pjd
This commit is contained in:
parent
07b6a9bed8
commit
cdea4c5e89
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=171776
@ -1136,7 +1136,15 @@ dump_label(const char *dev)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
psize = statbuf.st_size;
|
if (S_ISCHR(statbuf.st_mode)) {
|
||||||
|
if (ioctl(fd, DIOCGMEDIASIZE, &psize) != 0) {
|
||||||
|
(void) printf("failed to get size '%s': %s\n", dev,
|
||||||
|
strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
psize = statbuf.st_size;
|
||||||
|
|
||||||
psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
|
psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
|
||||||
|
|
||||||
for (l = 0; l < VDEV_LABELS; l++) {
|
for (l = 0; l < VDEV_LABELS; l++) {
|
||||||
|
@ -1136,7 +1136,15 @@ dump_label(const char *dev)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
psize = statbuf.st_size;
|
if (S_ISCHR(statbuf.st_mode)) {
|
||||||
|
if (ioctl(fd, DIOCGMEDIASIZE, &psize) != 0) {
|
||||||
|
(void) printf("failed to get size '%s': %s\n", dev,
|
||||||
|
strerror(errno));
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
psize = statbuf.st_size;
|
||||||
|
|
||||||
psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
|
psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
|
||||||
|
|
||||||
for (l = 0; l < VDEV_LABELS; l++) {
|
for (l = 0; l < VDEV_LABELS; l++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user