Skip to content

Commit

Permalink
Fix 'zpool history' sometimes fails without reporting any error
Browse files Browse the repository at this point in the history
The libzfs would printing an error messages by itself when the ioctl call
failed, but not when the nvlist decoding has failed.

Signed-off-by: WHR <msl0000023508@gmail.com>
  • Loading branch information
Low-power committed Apr 12, 2022
1 parent 35d81a7 commit 0e85df9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9477,8 +9477,16 @@ get_history_one(zpool_handle_t *zhp, void *data)
(void) printf(gettext("History for '%s':\n"), zpool_get_name(zhp));

while (!eof) {
if ((ret = zpool_get_history(zhp, &nvhis, &off, &eof)) != 0)
if ((ret = zpool_get_history(zhp, &nvhis, &off, &eof)) != 0) {
if (ret > 0) {
/* ret will be errno when the error message
* didn't get printed by libzfs itself. */
(void) fprintf(stderr, gettext("cannot get "
"history for pool '%s': %s\n"),
zpool_get_name(zhp), strerror(ret));
}
return (ret);
}

print_history_records(nvhis, cb);
nvlist_free(nvhis);
Expand Down

0 comments on commit 0e85df9

Please sign in to comment.