Message ID | 1429673927-3854-1-git-send-email-ce3g8jdj@umail.furryterror.org (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On Tue, Apr 21, 2015 at 11:38:47PM -0400, Zygo Blaxell wrote: > The BTRFS_IOC_RESIZE ioctl returns 0 on success, negative for POSIX > errors, and positive for btrfs-specific errors. > > If resize fails with a btrfs-specific error, decode the error and > report it. If we can't decode the error, report its numeric value so > that the userspace tool is not instantly useless when a new error code > is defined in the kernel. > > Exit with non-zero status on any resize error. This is very important > for scripts that will shrink the underlying storage when btrfs reports > success! Added the signed-off-by and applied, thanks. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/cmds-filesystem.c b/cmds-filesystem.c index f3fc160..85f0406 100644 --- a/cmds-filesystem.c +++ b/cmds-filesystem.c @@ -1263,6 +1263,16 @@ static int cmd_resize(int argc, char **argv) fprintf(stderr, "ERROR: unable to resize '%s' - %s\n", path, strerror(e)); return 1; + } else if (res > 0) { + const char *err_str = btrfs_err_str(res); + if (err_str) { + fprintf(stderr, "ERROR: btrfs error resizing '%s' - %s\n", + path, err_str); + } else { + fprintf(stderr, "ERROR: btrfs error resizing '%s' - unknown btrfs_err_code %d\n", + path, res); + } + return 1; } return 0; }