Index: stable/11/tools/tools/bootparttest/stub.c =================================================================== --- stable/11/tools/tools/bootparttest/stub.c (revision 322214) +++ stable/11/tools/tools/bootparttest/stub.c (revision 322215) @@ -1,52 +1,53 @@ /*- * Copyright (c) 2012 Andrey V. Elsukov * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ #include __FBSDID("$FreeBSD$"); #include #include void* Malloc(size_t size, const char *file, int line) { return (malloc(size)); } void Free(void *ptr, const char *file, int line) { return (free(ptr)); } -void +int pager_output(const char *s) { printf("%s", s); + return (0); } Index: stable/11/tools/tools/zfsboottest/zfsboottest.c =================================================================== --- stable/11/tools/tools/zfsboottest/zfsboottest.c (revision 322214) +++ stable/11/tools/tools/zfsboottest/zfsboottest.c (revision 322215) @@ -1,205 +1,206 @@ /*- * Copyright (c) 2010 Doug Rabson * Copyright (c) 2011 Andriy Gapon * Copyright (c) 2011 Pawel Jakub Dawidek * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define NBBY 8 -void +int pager_output(const char *line) { fprintf(stderr, "%s", line); + return (0); } #define ZFS_TEST #define printf(...) fprintf(stderr, __VA_ARGS__) #include "libzfs.h" #include "zfsimpl.c" #undef printf static int vdev_read(vdev_t *vdev, void *priv, off_t off, void *buf, size_t bytes) { int fd = *(int *)priv; if (pread(fd, buf, bytes, off) != bytes) return (-1); return (0); } static int zfs_read(spa_t *spa, dnode_phys_t *dn, void *buf, size_t size, off_t off) { const znode_phys_t *zp = (const znode_phys_t *) dn->dn_bonus; size_t n; int rc; n = size; if (off + n > zp->zp_size) n = zp->zp_size - off; rc = dnode_read(spa, dn, off, buf, n); if (rc != 0) return (-rc); return (n); } int main(int argc, char** argv) { char buf[512], hash[33]; MD5_CTX ctx; struct stat sb; struct zfsmount zfsmnt; dnode_phys_t dn; #if 0 uint64_t rootobj; #endif spa_t *spa; off_t off; ssize_t n; int i, failures, *fd; zfs_init(); if (argc == 1) { static char *av[] = { "zfsboottest", "/dev/gpt/system0", "/dev/gpt/system1", "-", "/boot/zfsloader", "/boot/support.4th", "/boot/kernel/kernel", NULL, }; argc = sizeof(av) / sizeof(av[0]) - 1; argv = av; } for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-") == 0) break; } fd = malloc(sizeof(fd[0]) * (i - 1)); if (fd == NULL) errx(1, "Unable to allocate memory."); for (i = 1; i < argc; i++) { if (strcmp(argv[i], "-") == 0) break; fd[i - 1] = open(argv[i], O_RDONLY); if (fd[i - 1] == -1) { warn("open(%s) failed", argv[i]); continue; } if (vdev_probe(vdev_read, &fd[i - 1], NULL) != 0) { warnx("vdev_probe(%s) failed", argv[i]); close(fd[i - 1]); } } STAILQ_FOREACH(spa, &zfs_pools, spa_link) { if (zfs_spa_init(spa)) { fprintf(stderr, "can't init pool %s\n", spa->spa_name); exit(1); } } spa_all_status(); spa = STAILQ_FIRST(&zfs_pools); if (spa == NULL) { fprintf(stderr, "no pools\n"); exit(1); } #if 0 uint64_t rootobj; if (zfs_get_root(spa, &rootobj)) { fprintf(stderr, "can't get root\n"); exit(1); } if (zfs_mount(spa, rootobj, &zfsmnt)) { #else if (zfs_mount(spa, 0, &zfsmnt)) { fprintf(stderr, "can't mount\n"); exit(1); #endif } printf("\n"); for (++i, failures = 0; i < argc; i++) { if (zfs_lookup(&zfsmnt, argv[i], &dn)) { fprintf(stderr, "%s: can't lookup\n", argv[i]); failures++; continue; } if (zfs_dnode_stat(spa, &dn, &sb)) { fprintf(stderr, "%s: can't stat\n", argv[i]); failures++; continue; } off = 0; MD5Init(&ctx); do { 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, "%s: zfs_read failed\n", argv[i]); failures++; break; } MD5Update(&ctx, buf, n); off += n; } while (off < sb.st_size); if (off < sb.st_size) continue; MD5End(&ctx, hash); printf("%s %s\n", hash, argv[i]); } return (failures == 0 ? 0 : 1); } Index: stable/11 =================================================================== --- stable/11 (revision 322214) +++ stable/11 (revision 322215) Property changes on: stable/11 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head:r321849,321852