VFS quota: report per mount-point space limits
authorFrancois Tigeot <ftigeot@wolfpond.org>
Sat, 17 Mar 2012 18:30:55 +0000 (19:30 +0100)
committerFran├žois Tigeot <ftigeot@wolfpond.org>
Mon, 16 Apr 2012 12:53:34 +0000 (14:53 +0200)
sbin/vquota/vquota.c
sys/kern/vfs_quota.c

index b532420..49712b0 100644 (file)
@@ -490,7 +490,7 @@ show_mp(char *path)
        prop_object_iterator_t  iter;
        prop_dictionary_t item;
        uint32_t id;
-       uint64_t space;
+       uint64_t space, limit=0;
        char hbuf[5];
 
        args = prop_dictionary_create();
@@ -523,6 +523,7 @@ show_mp(char *path)
 
        while ((item = prop_object_iterator_next(iter)) != NULL) {
                rv = prop_dictionary_get_uint64(item, "space used", &space);
+               rv = prop_dictionary_get_uint64(item, "limit", &limit);
                if (prop_dictionary_get_uint32(item, "uid", &id))
                        print_user(id);
                else if (prop_dictionary_get_uint32(item, "gid", &id))
@@ -531,9 +532,19 @@ show_mp(char *path)
                        printf("total:");
                if (flag_humanize) {
                        humanize_number(hbuf, sizeof(hbuf), space, "", HN_AUTOSCALE, HN_NOSPACE);
-                       printf(" %s\n", hbuf);
+                       printf(" %s", hbuf);
+               } else {
+                       printf(" %"PRIu64, space);
+               }
+               if (limit == 0) {
+                       printf("\n");
+                       continue;
+               }
+               if (flag_humanize) {
+                       humanize_number(hbuf, sizeof(hbuf), limit, "", HN_AUTOSCALE, HN_NOSPACE);
+                       printf(", limit = %s\n", hbuf);
                } else {
-                       printf(" %" PRIu64 "\n", space);
+                       printf(", limit = %"PRIu64"\n", limit);
                }
        }
        prop_object_iterator_release(iter);
index 84959d9..b6c705d 100644 (file)
@@ -181,6 +181,7 @@ cmd_get_usage_all(struct mount *mp, prop_array_t dict_out)
 
        item = prop_dictionary_create();
        (void) prop_dictionary_set_uint64(item, "space used", mp->mnt_acct.ac_bytes);
+       (void) prop_dictionary_set_uint64(item, "limit", mp->mnt_acct.ac_limit);
        prop_array_add_and_rel(dict_out, item);
 
        RB_FOREACH(unp, ac_utree, &mp->mnt_acct.ac_uroot) {
@@ -191,6 +192,8 @@ cmd_get_usage_all(struct mount *mp, prop_array_t dict_out)
                                        (unp->left_bits << ACCT_CHUNK_BITS) + i);
                                (void) prop_dictionary_set_uint64(item, "space used",
                                        unp->uid_chunk[i].space);
+                               (void) prop_dictionary_set_uint64(item, "limit",
+                                       unp->uid_chunk[i].limit);
                                prop_array_add_and_rel(dict_out, item);
                        }
                }
@@ -204,6 +207,8 @@ cmd_get_usage_all(struct mount *mp, prop_array_t dict_out)
                                        (gnp->left_bits << ACCT_CHUNK_BITS) + i);
                                (void) prop_dictionary_set_uint64(item, "space used",
                                        gnp->gid_chunk[i].space);
+                               (void) prop_dictionary_set_uint64(item, "limit",
+                                       gnp->gid_chunk[i].limit);
                                prop_array_add_and_rel(dict_out, item);
                        }
                }