From owner-svn-src-head@freebsd.org Wed Jul 20 11:15:34 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 4ECF7B9A677; Wed, 20 Jul 2016 11:15:34 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0AD6F1B2E; Wed, 20 Jul 2016 11:15:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u6KBFX7A082973; Wed, 20 Jul 2016 11:15:33 GMT (envelope-from avg@FreeBSD.org) Received: (from avg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u6KBFXcE082971; Wed, 20 Jul 2016 11:15:33 GMT (envelope-from avg@FreeBSD.org) Message-Id: <201607201115.u6KBFXcE082971@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avg set sender to avg@FreeBSD.org using -f From: Andriy Gapon Date: Wed, 20 Jul 2016 11:15:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r303086 - head/cddl/contrib/opensolaris/cmd/zdb X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jul 2016 11:15:34 -0000 Author: avg Date: Wed Jul 20 11:15:32 2016 New Revision: 303086 URL: https://svnweb.freebsd.org/changeset/base/303086 Log: MFV r303083: 7164 zdb should be able to open the root dataset Note: conversion of the manual page change from roff to mdoc is mine. illumos/illumos-gate@b702644a6eb66615d67b492fd73ecd9efa11fc7d https://github.com/illumos/illumos-gate/commit/b702644a6eb66615d67b492fd73ecd9efa11fc7d https://www.illumos.org/issues/7164 If the pool/dataset command-line argument is specified with a trailing slash, for example, "tank/", we should interpret it as the topmost dataset (rather than the whole pool) Reviewed by: Pavel Zakharov Reviewed by: Matthew Ahrens Approved by: Robert Mustacchi Author: Tim Chase PR: 204661 MFC after: 1 week Relnotes: yes Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.8 head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Directory Properties: head/cddl/contrib/opensolaris/cmd/zdb/ (props changed) Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.8 ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Wed Jul 20 11:04:49 2016 (r303085) +++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.8 Wed Jul 20 11:15:32 2016 (r303086) @@ -86,6 +86,17 @@ pool, and is inherently unstable. The precise output of most invocations is not documented, a knowledge of ZFS internals is assumed. .Pp +If the +.Ar dataset +argument does not contain any +.Sy / +or +.Sy @ +characters, it is interpreted as a pool name. +The root dataset can be specified as +.Pa pool Ns Sy / +(pool name followed by a slash). +.Pp When operating on an imported and active pool it is possible, though unlikely, that zdb may interpret inconsistent pool data and behave erratically. .Sh OPTIONS Modified: head/cddl/contrib/opensolaris/cmd/zdb/zdb.c ============================================================================== --- head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Jul 20 11:04:49 2016 (r303085) +++ head/cddl/contrib/opensolaris/cmd/zdb/zdb.c Wed Jul 20 11:15:32 2016 (r303086) @@ -3559,6 +3559,7 @@ main(int argc, char **argv) uint64_t max_txg = UINT64_MAX; int rewind = ZPOOL_NEVER_REWIND; char *spa_config_path_env; + boolean_t target_is_spa = B_TRUE; (void) setrlimit(RLIMIT_NOFILE, &rl); (void) enable_extended_FILE_stdio(-1, -1); @@ -3738,8 +3739,23 @@ main(int argc, char **argv) } } + if (strpbrk(target, "/@") != NULL) { + size_t targetlen; + + target_is_spa = B_FALSE; + /* + * Remove any trailing slash. Later code would get confused + * by it, but we want to allow it so that "pool/" can + * indicate that we want to dump the topmost filesystem, + * rather than the whole pool. + */ + targetlen = strlen(target); + if (targetlen != 0 && target[targetlen - 1] == '/') + target[targetlen - 1] = '\0'; + } + if (error == 0) { - if (strpbrk(target, "/@") == NULL || dump_opt['R']) { + if (target_is_spa || dump_opt['R']) { error = spa_open_rewind(target, &spa, FTAG, policy, NULL); if (error) {