summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authoravg <avg@FreeBSD.org>2011-09-16 08:24:31 +0000
committeravg <avg@FreeBSD.org>2011-09-16 08:24:31 +0000
commit4d4f51c9f49acd0db0afbc9220a8c3a1e4e74511 (patch)
treeaff6142c357d6cf389e61303872a96a09036f9e6 /tools
parentff769d30aa07ca8f26c4902fe71316e425193e43 (diff)
downloadFreeBSD-src-4d4f51c9f49acd0db0afbc9220a8c3a1e4e74511.zip
FreeBSD-src-4d4f51c9f49acd0db0afbc9220a8c3a1e4e74511.tar.gz
zfsboottest: some additional enhancements
- redirect diagnostics printfs in the boot code to stderr - do not read trailing garbage from a trailing block of a file Also add my copyright to the file after making so many changes. Approved by: re (kib) MFC after: 1 week
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/zfsboottest/zfsboottest.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/tools/zfsboottest/zfsboottest.c b/tools/tools/zfsboottest/zfsboottest.c
index 3e32da5..78a67bc 100644
--- a/tools/tools/zfsboottest/zfsboottest.c
+++ b/tools/tools/zfsboottest/zfsboottest.c
@@ -1,5 +1,6 @@
/*-
* Copyright (c) 2010 Doug Rabson
+ * Copyright (c) 2011 Andriy Gapon
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,9 +25,6 @@
* SUCH DAMAGE.
*/
/* $FreeBSD$ */
-/*
- * Compile with 'cc -I. -I../../cddl/boot/zfs zfstest.c -o zfstest'
- */
#include <sys/param.h>
#include <sys/queue.h>
@@ -48,7 +46,10 @@ pager_output(const char *line)
fprintf(stderr, "%s", line);
}
+#define ZFS_TEST
+#define printf(...) fprintf(stderr, __VA_ARGS__)
#include "zfsimpl.c"
+#undef printf
static int
vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes)
@@ -86,7 +87,9 @@ main(int argc, char** argv)
struct stat sb;
dnode_phys_t dn;
spa_t *spa;
- int i, n, off;
+ off_t off;
+ ssize_t n;
+ int i;
zfs_init();
if (argc == 1) {
@@ -131,7 +134,9 @@ main(int argc, char** argv)
off = 0;
do {
- n = zfs_read(spa, &dn, buf, 512, off);
+ n = sb.st_size - off;
+ n = n > sizeof(buf) ? sizeof(buf) : n;
+ n = zfs_read(spa, &dn, buf, n, off);
if (n < 0) {
fprintf(stderr, "zfs_read failed\n");
exit(1);
OpenPOWER on IntegriCloud