From a8132796d285bc7f1a112c4c206814a09a7bb012 Mon Sep 17 00:00:00 2001 From: Andrew Perepechko Date: Mon, 15 Mar 2010 14:55:38 +0300 Subject: [PATCH] b=22194 lfs quota output cleanup Suppress standard output in error cases o=Joseph Herring (LLNL) i=Johann Lombardi i=Andrew Perepechko --- lustre/utils/lfs.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index a2ca099..409fb41 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -2265,9 +2265,6 @@ ug_output: return CMD_HELP; } - if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) - print_quota_title(name, &qctl); - mnt = argv[optind]; version = llapi_server_major_version(mnt); if (version < 0) @@ -2275,13 +2272,31 @@ ug_output: rc1 = llapi_quotactl(mnt, &qctl); if (rc1 == -1) { - if ((version >= SERVER_MAJOR_VERSION_V2 && errno == EALREADY) || - (version < SERVER_MAJOR_VERSION_V2 && errno == ESRCH)) { - fprintf(stderr, "\n%s quotas are not enabled.\n", - qctl.qc_type == USRQUOTA ? "user" : "group"); + switch (errno) { + case EPERM: + fprintf(stderr, "Permission denied.\n"); + case ENOENT: + /* We already got a "No such file..." message. */ goto out; + case EALREADY: + case ESRCH: + if ((version >= SERVER_MAJOR_VERSION_V2 && + errno == EALREADY) || + (version < SERVER_MAJOR_VERSION_V2 && + errno == ESRCH)) { + fprintf(stderr, "%s quotas are not enabled.\n", + qctl.qc_type == USRQUOTA?"user":"group"); + goto out; + } + default: + fprintf(stderr, "Unexpected quotactl error: %s\n", + strerror(errno)); } } + + if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA) + print_quota_title(name, &qctl); + if (rc1 && *obd_type) fprintf(stderr, "%s %s ", obd_type, obd_uuid); @@ -2307,7 +2322,7 @@ out: if (pass == 1) goto ug_output; - return 0; + return rc1; } #endif /* HAVE_SYS_QUOTA_H! */ -- 1.8.3.1