Add debian packaging for tune2fs-fix-quota-enablement-regression

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
diff --git a/debian/patches/series b/debian/patches/series
index bdc6d22..8fa1f64 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,2 +1,3 @@
 e2fsprogs-1.43.4-release-fixup
 enable-metadata_csum-by-default
+tune2fs-fix-quota-enablement-regression
diff --git a/debian/patches/tune2fs-fix-quota-enablement-regression b/debian/patches/tune2fs-fix-quota-enablement-regression
new file mode 100644
index 0000000..f46ad03
--- /dev/null
+++ b/debian/patches/tune2fs-fix-quota-enablement-regression
@@ -0,0 +1,71 @@
+From: Eric Whitney <enwlinux@gmail.com>
+Description: tune2fs: fix quota enablement regression
+ Commit 5c2a665afa (Avoid dereferencing beyond allocated memory in quota
+ handling) induced a quota enablement regression in tune2fs.  Attempts
+ to enable a particular quota type (tune2fs -O project <dev>, for
+ example) set the appropriate feature flag in the superblock but the
+ quota file for the type is not initialized.
+ . 
+ The regression prevents the current version of xfstests from running
+ generic/383, 384, 385, and 386 (all project quota tests) with e2fsprogs
+ 1.43.4.  These tests exit with the message "Installed kernel does not
+ support project quotas", but the actual problem is that the project
+ quota file is not present.
+Origin: upstream, commit: 5f82cc95b31f87c62f18848142597d094fe966ee
+---
+ misc/tune2fs.c | 20 ++++++++++----------
+ 1 file changed, 10 insertions(+), 10 deletions(-)
+
+diff --git a/misc/tune2fs.c b/misc/tune2fs.c
+index 62395776..f1bad606 100644
+--- a/misc/tune2fs.c
++++ b/misc/tune2fs.c
+@@ -1483,7 +1483,7 @@ static void handle_quota_options(ext2_filsys fs)
+ 	quota_ctx_t qctx;
+ 	ext2_ino_t qf_ino;
+ 	enum quota_type qtype;
+-	int enable = 0;
++	unsigned int qtype_bits = 0;
+ 
+ 	for (qtype = 0 ; qtype < MAXQUOTAS; qtype++)
+ 		if (quota_enable[qtype] != 0)
+@@ -1492,19 +1492,19 @@ static void handle_quota_options(ext2_filsys fs)
+ 		/* Nothing to do. */
+ 		return;
+ 
+-	retval = quota_init_context(&qctx, fs, 0);
++	for (qtype = 0; qtype < MAXQUOTAS; qtype++) {
++		if (quota_enable[qtype] == QOPT_ENABLE)
++			qtype_bits |= 1 << qtype;
++	}
++
++	retval = quota_init_context(&qctx, fs, qtype_bits);
+ 	if (retval) {
+ 		com_err(program_name, retval,
+ 			_("while initializing quota context in support library"));
+ 		exit(1);
+ 	}
+-	for (qtype = 0 ; qtype < MAXQUOTAS; qtype++) {
+-		if (quota_enable[qtype] == QOPT_ENABLE) {
+-			enable = 1;
+-			break;
+-		}
+-	}
+-	if (enable)
++
++	if (qtype_bits)
+ 		quota_compute_usage(qctx);
+ 
+ 	for (qtype = 0 ; qtype < MAXQUOTAS; qtype++) {
+@@ -1540,7 +1540,7 @@ static void handle_quota_options(ext2_filsys fs)
+ 
+ 	quota_release_context(&qctx);
+ 
+-	if (enable) {
++	if (qtype_bits) {
+ 		ext2fs_set_feature_quota(fs->super);
+ 		ext2fs_mark_super_dirty(fs);
+ 	} else {
+-- 
+2.11.0.rc0.7.gbe5a750
+