Whamcloud - gitweb
LU-8631 quota: better error message for 'lfs quota' 21/23021/4
authorNiu Yawei <yawei.niu@intel.com>
Sat, 8 Oct 2016 02:56:23 +0000 (22:56 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 25 Oct 2016 02:23:41 +0000 (02:23 +0000)
'lfs quota' should return useful error message when it's being
issued on a non-Lustre fs.

Signed-off-by: Niu Yawei <yawei.niu@intel.com>
Change-Id: I9dd08982077132756c8684b44430251da53cbb90
Reviewed-on: http://review.whamcloud.com/23021
Tested-by: Jenkins
Reviewed-by: Fan Yong <fan.yong@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Yang Sheng <yang.sheng@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/utils/lfs.c
lustre/utils/liblustreapi.c

index 93442af..9ba0757 100644 (file)
@@ -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);
index abe6c77..820d28d 100644 (file)
@@ -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) {