From owner-svn-src-all@FreeBSD.ORG Fri Sep 16 08:24:31 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 98E8E106566B; Fri, 16 Sep 2011 08:24:31 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 88A148FC14; Fri, 16 Sep 2011 08:24:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p8G8OVPb011132; Fri, 16 Sep 2011 08:24:31 GMT (envelope-from avg@svn.freebsd.org) Received: (from avg@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p8G8OV3D011130; Fri, 16 Sep 2011 08:24:31 GMT (envelope-from avg@svn.freebsd.org) Message-Id: <201109160824.p8G8OV3D011130@svn.freebsd.org> From: Andriy Gapon Date: Fri, 16 Sep 2011 08:24:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r225609 - head/tools/tools/zfsboottest X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Sep 2011 08:24:31 -0000 Author: avg Date: Fri Sep 16 08:24:31 2011 New Revision: 225609 URL: http://svn.freebsd.org/changeset/base/225609 Log: 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 Modified: head/tools/tools/zfsboottest/zfsboottest.c Modified: head/tools/tools/zfsboottest/zfsboottest.c ============================================================================== --- head/tools/tools/zfsboottest/zfsboottest.c Fri Sep 16 08:22:48 2011 (r225608) +++ head/tools/tools/zfsboottest/zfsboottest.c Fri Sep 16 08:24:31 2011 (r225609) @@ -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 #include @@ -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);