Blame SOURCES/xfsprogs-5.8.0-xfs_quota-command-error-message-improvement.patch

ffb978
From ca42fa70929e88781e7daeee4cf4588adb834661 Mon Sep 17 00:00:00 2001
ffb978
From: Bill O'Donnell <billodo@redhat.com>
ffb978
Date: Mon, 24 Aug 2020 13:23:23 -0400
ffb978
Subject: [PATCH] xfs_quota: command error message improvement
ffb978
ffb978
Make the error messages for rudimentary xfs_quota commands
ffb978
(off, enable, disable) more user friendly, instead of the
ffb978
terse sys error outputs.
ffb978
ffb978
Signed-off-by: Bill O'Donnell <billodo@redhat.com>
ffb978
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
ffb978
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
ffb978
---
ffb978
 quota/state.c | 32 ++++++++++++++++++++++++++------
ffb978
 1 file changed, 26 insertions(+), 6 deletions(-)
ffb978
ffb978
diff --git a/quota/state.c b/quota/state.c
ffb978
index 8f9718f1..7a595fc6 100644
ffb978
--- a/quota/state.c
ffb978
+++ b/quota/state.c
ffb978
@@ -306,8 +306,16 @@ enable_enforcement(
ffb978
 		return;
ffb978
 	}
ffb978
 	dir = mount->fs_name;
ffb978
-	if (xfsquotactl(XFS_QUOTAON, dir, type, 0, (void *)&qflags) < 0)
ffb978
-		perror("XFS_QUOTAON");
ffb978
+	if (xfsquotactl(XFS_QUOTAON, dir, type, 0, (void *)&qflags) < 0) {
ffb978
+		if (errno == EEXIST)
ffb978
+			fprintf(stderr,
ffb978
+				_("Quota enforcement already enabled.\n"));
ffb978
+		else if (errno == EINVAL || errno == ENOSYS)
ffb978
+			fprintf(stderr,
ffb978
+				_("Can't enable enforcement when quota off.\n"));
ffb978
+		else
ffb978
+			perror("XFS_QUOTAON");
ffb978
+	}
ffb978
 	else if (flags & VERBOSE_FLAG)
ffb978
 		state_quotafile_mount(stdout, type, mount, flags);
ffb978
 }
ffb978
@@ -328,8 +336,16 @@ disable_enforcement(
ffb978
 		return;
ffb978
 	}
ffb978
 	dir = mount->fs_name;
ffb978
-	if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0)
ffb978
-		perror("XFS_QUOTAOFF");
ffb978
+	if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) {
ffb978
+		if (errno == EEXIST)
ffb978
+			fprintf(stderr,
ffb978
+				_("Quota enforcement already disabled.\n"));
ffb978
+		else if (errno == EINVAL || errno == ENOSYS)
ffb978
+			fprintf(stderr,
ffb978
+				_("Can't disable enforcement when quota off.\n"));
ffb978
+		else
ffb978
+			perror("XFS_QUOTAOFF");
ffb978
+	}
ffb978
 	else if (flags & VERBOSE_FLAG)
ffb978
 		state_quotafile_mount(stdout, type, mount, flags);
ffb978
 }
ffb978
@@ -350,8 +366,12 @@ quotaoff(
ffb978
 		return;
ffb978
 	}
ffb978
 	dir = mount->fs_name;
ffb978
-	if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0)
ffb978
-		perror("XFS_QUOTAOFF");
ffb978
+	if (xfsquotactl(XFS_QUOTAOFF, dir, type, 0, (void *)&qflags) < 0) {
ffb978
+		if (errno == EEXIST || errno == ENOSYS)
ffb978
+			fprintf(stderr, _("Quota already off.\n"));
ffb978
+		else
ffb978
+			perror("XFS_QUOTAOFF");
ffb978
+	}
ffb978
 	else if (flags & VERBOSE_FLAG)
ffb978
 		state_quotafile_mount(stdout, type, mount, flags);
ffb978
 }
ffb978
-- 
ffb978
2.31.1
ffb978