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 <behlendorf1@llnl.gov>
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Giuseppe Di Natale <dinatale2@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #7454
This commit is contained in:
LOLi
2018-04-19 18:45:17 +02:00
committed by Brian Behlendorf
parent 599b864813
commit b4555c777a
10 changed files with 235 additions and 2 deletions
+18
View File
@@ -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);