From 64b279c3ec0e7a9960b3d33db8a64e0a53af9e82 Mon Sep 17 00:00:00 2001 From: Niu Yawei Date: Fri, 7 Oct 2016 22:56:23 -0400 Subject: [PATCH] LU-8631 quota: better error message for 'lfs quota' 'lfs quota' should return useful error message when it's being issued on a non-Lustre fs. Signed-off-by: Niu Yawei Change-Id: I9dd08982077132756c8684b44430251da53cbb90 Reviewed-on: http://review.whamcloud.com/23021 Tested-by: Jenkins Reviewed-by: Fan Yong Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Oleg Drokin --- lustre/utils/lfs.c | 33 +++++++++++++++++---------------- lustre/utils/liblustreapi.c | 12 ++++++++++-- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/lustre/utils/lfs.c b/lustre/utils/lfs.c index 93442af..9ba07579 100644 --- a/lustre/utils/lfs.c +++ b/lustre/utils/lfs.c @@ -3275,22 +3275,23 @@ ug_output: mnt = argv[optind]; rc1 = llapi_quotactl(mnt, &qctl); - if (rc1 < 0) { - switch (rc1) { - case -ESRCH: - fprintf(stderr, "%s quotas are not enabled.\n", - qctl.qc_type == USRQUOTA ? "user" : "group"); - goto out; - case -EPERM: - fprintf(stderr, "Permission denied.\n"); - case -ENOENT: - /* We already got a "No such file..." message. */ - goto out; - default: - fprintf(stderr, "Unexpected quotactl error: %s\n", - strerror(-rc1)); - } - } + if (rc1 < 0) { + switch (rc1) { + case -ESRCH: + fprintf(stderr, "%s quotas are not enabled.\n", + qctl.qc_type == USRQUOTA ? "user" : "group"); + goto out; + case -EPERM: + fprintf(stderr, "Permission denied.\n"); + case -ENODEV: + case -ENOENT: + /* We already got error message. */ + goto out; + default: + fprintf(stderr, "Unexpected quotactl error: %s\n", + strerror(-rc1)); + } + } if (qctl.qc_cmd == LUSTRE_Q_GETQUOTA && !quiet) print_quota_title(name, &qctl, human_readable); diff --git a/lustre/utils/liblustreapi.c b/lustre/utils/liblustreapi.c index abe6c77..820d28d 100644 --- a/lustre/utils/liblustreapi.c +++ b/lustre/utils/liblustreapi.c @@ -3525,8 +3525,16 @@ int llapi_is_lustre_mnt(struct mntent *mnt) int llapi_quotactl(char *mnt, struct if_quotactl *qctl) { - DIR *root; - int rc; + char fsname[PATH_MAX + 1]; + DIR *root; + int rc; + + rc = llapi_search_fsname(mnt, fsname); + if (rc) { + llapi_err_noerrno(LLAPI_MSG_ERROR, + "'%s' isn't on Lustre filesystem", mnt); + return rc; + } root = opendir(mnt); if (!root) { -- 1.8.3.1