Whamcloud - gitweb
b=22194 lfs quota output cleanup
authorAndrew Perepechko <Andrew.Perepechko@Sun.COM>
Mon, 15 Mar 2010 11:55:38 +0000 (14:55 +0300)
committerJohann Lombardi <johann@sun.com>
Tue, 16 Mar 2010 13:30:06 +0000 (14:30 +0100)
Suppress standard output in error cases

o=Joseph Herring  (LLNL)
i=Johann Lombardi
i=Andrew Perepechko

lustre/utils/lfs.c

index a2ca099..409fb41 100644 (file)
@@ -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! */