aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorHidetoshi Shimokawa <simokawa@FreeBSD.org>2007-08-07 12:42:03 +0000
committerHidetoshi Shimokawa <simokawa@FreeBSD.org>2007-08-07 12:42:03 +0000
commitcdea4c5e891f29ce3926f8b25a70e799ad70c289 (patch)
treec890d68579becb6857c3b064a51408128052c05a /contrib
parent07b6a9bed88c1fbc5ba03c7e3410f97f6e0b4647 (diff)
downloadsrc-cdea4c5e891f29ce3926f8b25a70e799ad70c289.tar.gz
src-cdea4c5e891f29ce3926f8b25a70e799ad70c289.zip
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
Notes
Notes: svn path=/head/; revision=171776
Diffstat (limited to 'contrib')
-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 03abc3a60e4f..2dc459dfabf0 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++) {