From bdc2923743f5541c2a72b5730c76bd96c45c9b18 Mon Sep 17 00:00:00 2001 From: Steve Guminski Date: Wed, 12 Jul 2017 14:56:58 -0400 Subject: [PATCH] LU-5170 lfs: Standardize error messages in lfs_check() 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 Change-Id: Ife0fa0b5f22f1099757c38d07b1827e26182426e Reviewed-on: https://review.whamcloud.com/30666 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Jian Yu --- lustre/utils/lfs.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index d6c7ecb..4c34482 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -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; } -- 1.8.3.1