Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2018 19:13:45 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r337163 - in head/cddl/contrib/opensolaris: cmd/zfs lib/libzfs/common
Message-ID:  <201808021913.w72JDjpo081449@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Thu Aug  2 19:13:45 2018
New Revision: 337163
URL: https://svnweb.freebsd.org/changeset/base/337163

Log:
  MFV r337161: 9512 zfs remap poolname@snapname coredumps
  
  Only filesystems and volumes are valid "zfs remap" parameters: when passed
  a snapshot name zfs_remap_indirects() does not handle the EINVAL returned
  from libzfs_core, which results in failing an assertion and consequently
  crashing.
  
  illumos/illumos-gate@0b2e8253986c5c761129b58cfdac46d204903de1
  
  Reviewed by: Matthew Ahrens <mahrens@delphix.com>
  Reviewed by: John Wren Kennedy <john.kennedy@delphix.com>
  Reviewed by: Sara Hartse <sara.hartse@delphix.com>
  Approved by: Matt Ahrens <mahrens@delphix.com>
  Author:     loli10K <ezomori.nozomu@gmail.com>

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Thu Aug  2 19:11:56 2018	(r337162)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c	Thu Aug  2 19:13:45 2018	(r337163)
@@ -7038,11 +7038,28 @@ zfs_do_diff(int argc, char **argv)
 	return (err != 0);
 }
 
+/*
+ * zfs remap <filesystem | volume>
+ *
+ * Remap the indirect blocks in the given fileystem or volume.
+ */
 static int
 zfs_do_remap(int argc, char **argv)
 {
 	const char *fsname;
 	int err = 0;
+	int c;
+
+	/* check options */
+	while ((c = getopt(argc, argv, "")) != -1) {
+		switch (c) {
+		case '?':
+			(void) fprintf(stderr,
+			    gettext("invalid option '%c'\n"), optopt);
+			usage(B_FALSE);
+		}
+	}
+
 	if (argc != 2) {
 		(void) fprintf(stderr, gettext("wrong number of arguments\n"));
 		usage(B_FALSE);

Modified: head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
==============================================================================
--- head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Thu Aug  2 19:11:56 2018	(r337162)
+++ head/cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	Thu Aug  2 19:13:45 2018	(r337163)
@@ -3917,12 +3917,24 @@ zfs_remap_indirects(libzfs_handle_t *hdl, const char *
 	char errbuf[1024];
 
 	(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
-	    "cannot remap filesystem '%s' "), fs);
+	    "cannot remap dataset '%s'"), fs);
 
 	err = lzc_remap(fs);
 
 	if (err != 0) {
-		(void) zfs_standard_error(hdl, err, errbuf);
+		switch (err) {
+		case ENOTSUP:
+			zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+			    "pool must be upgraded"));
+			(void) zfs_error(hdl, EZFS_BADVERSION, errbuf);
+			break;
+		case EINVAL:
+			(void) zfs_error(hdl, EZFS_BADTYPE, errbuf);
+			break;
+		default:
+			(void) zfs_standard_error(hdl, err, errbuf);
+			break;
+		}
 	}
 
 	return (err);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201808021913.w72JDjpo081449>