From: Steve Guminski Date: Wed, 12 Jul 2017 19:15:22 +0000 (-0400) Subject: LU-5170 lfs: Standardize error messages in lfs_data_version() X-Git-Tag: 2.11.52~50 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a92ac522b8af879851124180f4b81db2514cffaf;p=fs%2Flustre-release.git LU-5170 lfs: Standardize error messages in lfs_data_version() Error messages in lfs_data_version() 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: Idb0939c4fa23fc409d965183e5fe5dddcab6da4f Reviewed-on: https://review.whamcloud.com/30667 Reviewed-by: Andreas Dilger Tested-by: Jenkins Tested-by: Maloo Reviewed-by: James Nunez --- diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 5d18285..ec86880 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -6626,8 +6626,11 @@ static int lfs_data_version(int argc, char **argv) int c; int data_version_flags = LL_DV_RD_FLUSH; /* Read by default */ - if (argc < 2) + if (argc < 2) { + fprintf(stderr, "%s data_version: FILE must be specified\n", + progname); return CMD_HELP; + } while ((c = getopt(argc, argv, "nrw")) != -1) { switch (c) { @@ -6641,20 +6644,32 @@ static int lfs_data_version(int argc, char **argv) data_version_flags |= LL_DV_WR_FLUSH; break; default: + fprintf(stderr, + "%s data_version: unrecognized option '%s'\n", + progname, argv[optind - 1]); return CMD_HELP; } } - if (optind == argc) + if (optind == argc) { + fprintf(stderr, "%s data_version: FILE must be specified\n", + progname); return CMD_HELP; + } path = argv[optind]; fd = open(path, O_RDONLY); - if (fd < 0) - err(errno, "cannot open file %s", path); + if (fd < 0) { + rc = -errno; + fprintf(stderr, "%s data_version: cannot open file '%s': %s\n", + progname, path, strerror(-rc)); + return rc; + } rc = llapi_get_data_version(fd, &data_version, data_version_flags); if (rc < 0) - err(errno, "cannot get version for %s", path); + fprintf(stderr, + "%s data_version: cannot get version for '%s': %s\n", + progname, path, strerror(-rc)); else printf("%ju" "\n", (uintmax_t)data_version);