Whamcloud - gitweb
LU-11606 utils: Call llapi_error() for errors in liblustreapi files 77/33877/3
authorArshad Hussain <arshad.super@gmail.com>
Tue, 4 Dec 2018 12:45:48 +0000 (18:15 +0530)
committerOleg Drokin <green@whamcloud.com>
Fri, 4 Jan 2019 04:49:24 +0000 (04:49 +0000)
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 <arshad.super@gmail.com>
Reviewed-on: https://review.whamcloud.com/33877
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Tested-by: Jenkins
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/utils/liblustreapi.c

index 8f69ac6..78dc8a5 100644 (file)
@@ -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: