summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-05-10 01:09:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-05-13 10:12:15 -0400
commita0811c1a0ea18d4aebb4a16e7189501b80d4bc77 (patch)
tree27798b8c452509c63fcbb2d89b2a07eeec9910d6
parent4cf0b0fe443566940098308c2a9eb28fdb000166 (diff)
downloade2fsprogs-a0811c1a0ea18d4aebb4a16e7189501b80d4bc77.tar.gz
quota: add debugging code to print the dquot structure
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu> Reviewed-by: Aditya Kali <adityakali@google.com>
-rw-r--r--lib/quota/common.h1
-rw-r--r--lib/quota/mkquota.c19
2 files changed, 20 insertions, 0 deletions
diff --git a/lib/quota/common.h b/lib/quota/common.h
index 7d324bfc..f1ad79f2 100644
--- a/lib/quota/common.h
+++ b/lib/quota/common.h
@@ -13,6 +13,7 @@
#include <ext2fs/ext2_types.h>
#endif /* EXT2_FLAT_INCLUDES */
+/* #define DEBUG_QUOTA 1 */
#ifndef __attribute__
# if !defined __GNUC__ || __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 8) || __STRICT_ANSI__
diff --git a/lib/quota/mkquota.c b/lib/quota/mkquota.c
index ba8c2da6..3849ae12 100644
--- a/lib/quota/mkquota.c
+++ b/lib/quota/mkquota.c
@@ -45,6 +45,21 @@ static void print_inode(struct ext2_inode *inode)
return;
}
+
+static void print_dquot(const char *desc, struct dquot *dq)
+{
+ if (desc)
+ fprintf(stderr, "%s: ", desc);
+ fprintf(stderr, "%u %lld:%lld:%lld %lld:%lld:%lld\n",
+ dq->dq_id, dq->dq_dqb.dqb_curspace,
+ dq->dq_dqb.dqb_bsoftlimit, dq->dq_dqb.dqb_bhardlimit,
+ dq->dq_dqb.dqb_curinodes,
+ dq->dq_dqb.dqb_isoftlimit, dq->dq_dqb.dqb_ihardlimit);
+}
+#else
+static void print_dquot(const char *desc, struct dquot *dq)
+{
+}
#endif
/*
@@ -121,6 +136,7 @@ static void write_dquots(dict_t *dict, struct quota_handle *qh)
for (n = dict_first(dict); n; n = dict_next(dict, n)) {
dq = dnode_get(n);
if (dq) {
+ print_dquot("write", dq);
dq->dq_h = qh;
update_grace_times(dq);
qh->qh_ops->commit_dquot(dq);
@@ -444,6 +460,9 @@ static int scan_dquots_callback(struct dquot *dquot, void *cb_data)
dq->dq_id = dquot->dq_id;
dq->dq_dqb.u.v2_mdqb.dqb_off = dquot->dq_dqb.u.v2_mdqb.dqb_off;
+ print_dquot("mem", dq);
+ print_dquot("dsk", dquot);
+
/* Check if there is inconsistancy. */
if (dq->dq_dqb.dqb_curspace != dquot->dq_dqb.dqb_curspace ||
dq->dq_dqb.dqb_curinodes != dquot->dq_dqb.dqb_curinodes) {