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

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