Blame SOURCES/quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch

ecf77e
From 7b6dfd6390476ec7b811c76e4e2653db2994cad4 Mon Sep 17 00:00:00 2001
ecf77e
From: Jan Kara <jack@suse.cz>
ecf77e
Date: Mon, 5 Feb 2018 15:54:54 +0100
ecf77e
Subject: [PATCH] quotacheck: Report error when caching of quota file fails
ecf77e
MIME-Version: 1.0
ecf77e
Content-Type: text/plain; charset=UTF-8
ecf77e
Content-Transfer-Encoding: 8bit
ecf77e
ecf77e
Currently quotacheck returns with zero exit code even though caching of
ecf77e
quota file fails. Fix it to return with non-zero exit code in that case
ecf77e
as expected.
ecf77e
ecf77e
Reported-by: Christoph Biedl 
ecf77e
Signed-off-by: Jan Kara <jack@suse.cz>
ecf77e
Signed-off-by: Petr Písař <ppisar@redhat.com>
ecf77e
---
ecf77e
 quotacheck.c | 29 ++++++++++++++++++++++-------
ecf77e
 1 file changed, 22 insertions(+), 7 deletions(-)
ecf77e
ecf77e
diff --git a/quotacheck.c b/quotacheck.c
ecf77e
index 9d7940b..b1302b6 100644
ecf77e
--- a/quotacheck.c
ecf77e
+++ b/quotacheck.c
ecf77e
@@ -924,6 +924,7 @@ static int check_dir(struct mount_entry *mnt)
ecf77e
 	struct stat st;
ecf77e
 	int remounted = 0;
ecf77e
 	int failed = 0;
ecf77e
+	int ret;
ecf77e
 
ecf77e
 	if (lstat(mnt->me_dir, &st) < 0)
ecf77e
 		die(2, _("Cannot stat mountpoint %s: %s\n"), mnt->me_dir, strerror(errno));
ecf77e
@@ -939,14 +940,22 @@ static int check_dir(struct mount_entry *mnt)
ecf77e
 	 */
ecf77e
 	if (cfmt == QF_XFS)
ecf77e
 		goto start_scan;
ecf77e
-	if (ucheck)
ecf77e
-		if (process_file(mnt, USRQUOTA) < 0)
ecf77e
+	if (ucheck) {
ecf77e
+		ret = process_file(mnt, USRQUOTA);
ecf77e
+		if (ret < 0) {
ecf77e
+			failed |= ret;
ecf77e
 			ucheck = 0;
ecf77e
-	if (gcheck)
ecf77e
-		if (process_file(mnt, GRPQUOTA) < 0)
ecf77e
+		}
ecf77e
+	}
ecf77e
+	if (gcheck) {
ecf77e
+		ret = process_file(mnt, GRPQUOTA);
ecf77e
+		if (ret < 0) {
ecf77e
+			failed |= ret;
ecf77e
 			gcheck = 0;
ecf77e
+		}
ecf77e
+	}
ecf77e
 	if (!ucheck && !gcheck)	/* Nothing to check? */
ecf77e
-		return 0;
ecf77e
+		return failed;
ecf77e
 	if (!(flags & FL_NOREMOUNT)) {
ecf77e
 		/* Now we try to remount fs read-only to prevent races when scanning filesystem */
ecf77e
 		if (mount
ecf77e
@@ -978,8 +987,11 @@ start_scan:
ecf77e
 	    !strcmp(mnt->me_type, MNTTYPE_EXT3) ||
ecf77e
 	    !strcmp(mnt->me_type, MNTTYPE_NEXT3) ||
ecf77e
 	    !strcmp(mnt->me_type, MNTTYPE_EXT4)) {
ecf77e
-		if ((failed = ext2_direct_scan(mnt->me_devname)) < 0)
ecf77e
+		ret = ext2_direct_scan(mnt->me_devname);
ecf77e
+		if (ret < 0) {
ecf77e
+			failed |= ret;
ecf77e
 			goto out;
ecf77e
+		}
ecf77e
 	}
ecf77e
 	else {
ecf77e
 #else
ecf77e
@@ -987,8 +999,11 @@ start_scan:
ecf77e
 #endif
ecf77e
 		if (flags & FL_VERYVERBOSE)
ecf77e
 			putchar('\n');
ecf77e
-		if ((failed = scan_dir(mnt->me_dir)) < 0)
ecf77e
+		ret = scan_dir(mnt->me_dir);
ecf77e
+		if (ret < 0) {
ecf77e
+			failed |= ret;
ecf77e
 			goto out;
ecf77e
+		}
ecf77e
 	}
ecf77e
 	dirs_done++;
ecf77e
 	if (flags & FL_VERBOSE || flags & FL_DEBUG)
ecf77e
-- 
ecf77e
2.13.6
ecf77e