summaryrefslogtreecommitdiffstats
path: root/contrib/opensolaris/cmd
diff options
context:
space:
mode:
authorsimokawa <simokawa@FreeBSD.org>2007-08-07 12:42:03 +0000
committersimokawa <simokawa@FreeBSD.org>2007-08-07 12:42:03 +0000
commit194ebb69c9cede7bc316c640f88815f8591d4386 (patch)
treec890d68579becb6857c3b064a51408128052c05a /contrib/opensolaris/cmd
parentbe48e4d2b1abeab9580ad1481ce81a4cff762b93 (diff)
downloadFreeBSD-src-194ebb69c9cede7bc316c640f88815f8591d4386.zip
FreeBSD-src-194ebb69c9cede7bc316c640f88815f8591d4386.tar.gz
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
Diffstat (limited to 'contrib/opensolaris/cmd')
-rw-r--r--contrib/opensolaris/cmd/zdb/zdb.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/contrib/opensolaris/cmd/zdb/zdb.c b/contrib/opensolaris/cmd/zdb/zdb.c
index 03abc3a..2dc459d 100644
--- a/contrib/opensolaris/cmd/zdb/zdb.c
+++ b/contrib/opensolaris/cmd/zdb/zdb.c
@@ -1136,7 +1136,15 @@ dump_label(const char *dev)
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));
for (l = 0; l < VDEV_LABELS; l++) {
OpenPOWER on IntegriCloud