From 4983fa82bb2d26fe631bf32815a92733bf910007 Mon Sep 17 00:00:00 2001 From: Arshad Hussain Date: Tue, 4 Dec 2018 18:15:48 +0530 Subject: [PATCH] LU-11606 utils: Call llapi_error() for errors in liblustreapi files Change calls to remaining printf() and fprintf() to use llapi_printf() and llapi_error() so that it is possible to override these calls when liblustreapi is linked into some other application. Change-Id: I6531d29b05b34766a68dabf17299cd00babe2517 Signed-off-by: Arshad Hussain Reviewed-on: https://review.whamcloud.com/33877 Reviewed-by: Andreas Dilger Reviewed-by: Ben Evans Tested-by: Jenkins Reviewed-by: James Simmons Tested-by: Maloo --- lustre/utils/liblustreapi.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index 8f69ac6..78dc8a5 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -290,8 +290,9 @@ int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len) data->ioc_version = OBD_IOCTL_VERSION; if (*pbuf != NULL && data->ioc_len > max_len) { - fprintf(stderr, "pbuf = %p, ioc_len = %u, max_len = %d\n", - *pbuf, data->ioc_len, max_len); + llapi_error(LLAPI_MSG_ERROR, -EINVAL, + "pbuf = %p, ioc_len = %u, max_len = %d\n", + *pbuf, data->ioc_len, max_len); return -EINVAL; } @@ -4482,19 +4483,22 @@ migrate: goto migrate; } else if (errno == EALREADY) { if (param->fp_verbose & VERBOSE_DETAIL) - fprintf(stdout, - "%s was migrated to MDT%d already\n", - path, lmu->lum_stripe_offset); + llapi_printf(LLAPI_MSG_NORMAL, + "%s was migrated to MDT%d already\n", + path, lmu->lum_stripe_offset); ret = 0; } else { ret = -errno; - fprintf(stderr, "%s migrate failed: %s (%d)\n", - path, strerror(-ret), ret); + llapi_error(LLAPI_MSG_ERROR, ret, + "%s migrate failed: %s (%d)\n", + path, strerror(-ret), ret); goto out; } } else if (param->fp_verbose & VERBOSE_DETAIL) { - fprintf(stdout, "migrate %s to MDT%d stripe count %d\n", - path, lmu->lum_stripe_offset, lmu->lum_stripe_count); + llapi_printf(LLAPI_MSG_NORMAL, + "migrate %s to MDT%d stripe count %d\n", + path, lmu->lum_stripe_offset, + lmu->lum_stripe_count); } out: -- 1.8.3.1