summaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorLOLi <[email protected]>2018-04-19 18:45:17 +0200
committerBrian Behlendorf <[email protected]>2018-04-19 09:45:17 -0700
commitb4555c777a0be3c0dba29662d278c57099c60a87 (patch)
tree5e2c2e713a6c9d38ba9d5b993009be1419f39084 /cmd
parent599b8648133738b524ff4c58a72fc744b62fe142 (diff)
Fix 'zfs remap <poolname@snapname>'
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. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed by: Matthew Ahrens <[email protected]> Reviewed-by: Giuseppe Di Natale <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #7454
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zfs/zfs_main.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c
index 45d9a661b..7d81dcaee 100644
--- a/cmd/zfs/zfs_main.c
+++ b/cmd/zfs/zfs_main.c
@@ -7108,11 +7108,29 @@ 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);