Whamcloud - gitweb
LU-5170 lfs: Standardize error messages in lfs_check() 66/30666/2
authorSteve Guminski <stephenx.guminski@intel.com>
Wed, 12 Jul 2017 18:56:58 +0000 (14:56 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 9 Jan 2018 05:36:28 +0000 (05:36 +0000)
Error messages in lfs_check() are updated to a standard format.
Messages are prefixed with the name of the utility and the command
that caused the error.  User-provided values are delimited with
single quotes.

Test-Parameters: trivial
Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: Ife0fa0b5f22f1099757c38d07b1827e26182426e
Reviewed-on: https://review.whamcloud.com/30666
Tested-by: Jenkins
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Jian Yu <jian.yu@intel.com>
lustre/utils/lfs.c

index d6c7ecb..4c34482 100644 (file)
@@ -4245,8 +4245,11 @@ static int lfs_check(int argc, char **argv)
         char obd_type1[4];
         char obd_type2[4];
 
-        if (argc != 2)
-                return CMD_HELP;
+       if (argc != 2) {
+               fprintf(stderr, "%s check: server type must be specified\n",
+                       progname);
+               return CMD_HELP;
+       }
 
         obd_types[0] = obd_type1;
         obd_types[1] = obd_type2;
@@ -4259,24 +4262,26 @@ static int lfs_check(int argc, char **argv)
                 num_types = 2;
                 strcpy(obd_types[0], "osc");
                 strcpy(obd_types[1], "mdc");
-        } else {
-                fprintf(stderr, "error: %s: option '%s' unrecognized\n",
-                                argv[0], argv[1]);
-                        return CMD_HELP;
-        }
+       } else {
+               fprintf(stderr, "%s check: unrecognized option '%s'\n",
+                       progname, argv[1]);
+               return CMD_HELP;
+       }
 
         rc = llapi_search_mounts(NULL, 0, mntdir, NULL);
-        if (rc < 0 || mntdir[0] == '\0') {
-                fprintf(stderr, "No suitable Lustre mount found\n");
-                return rc;
-        }
+       if (rc < 0 || mntdir[0] == '\0') {
+               fprintf(stderr,
+                       "%s check: cannot find mounted Lustre filesystem: %s\n",
+                       progname, (rc < 0) ? strerror(-rc) : strerror(ENODEV));
+               return rc;
+       }
 
        rc = llapi_target_check(num_types, obd_types, mntdir);
-        if (rc)
-                fprintf(stderr, "error: %s: %s status failed\n",
-                                argv[0],argv[1]);
+       if (rc)
+               fprintf(stderr, "%s check: cannot check target '%s': %s\n",
+                       progname, argv[1], strerror(-rc));
 
-        return rc;
+       return rc;
 
 }