[PATCH] xfs_quota: Don't ignore every error when asking for quota.

Arkadiusz Miskiewicz arekm at maven.pl
Tue Dec 16 01:53:08 CST 2008


Errors from quotactl() were silently ignored like:

$ xfs_quota -x -c "report -u -L 12000 -U 12001"
$

Print error messages for conditions other than ENOENT and ENOSYS
(these two aren't actually errors for the way quotactl is used).

We now get:

$ ./xfs_quota -x -c "report -u -L 12000 -U 12001"  /home
XFS_GETQUOTA: Operation not permitted
XFS_GETQUOTA: Operation not permitted
$

which is consistent with error reporting in rest of quotactl using code.
---
 xfsprogs/quota/report.c |   28 ++++++++++++++++++++--------
 1 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/xfsprogs/quota/report.c b/xfsprogs/quota/report.c
index 2184158..73248d0 100644
--- a/xfsprogs/quota/report.c
+++ b/xfsprogs/quota/report.c
@@ -81,8 +81,11 @@ dump_file(
 {
 	fs_disk_quota_t	d;
 
-	if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0)
+	if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0) {
+		if (errno != ENOENT && errno != ENOSYS)
+			perror("XFS_GETQUOTA");
 		return;
+	}
 	if (!d.d_blk_softlimit && !d.d_blk_hardlimit &&
 	    !d.d_ino_softlimit && !d.d_ino_hardlimit &&
 	    !d.d_rtb_softlimit && !d.d_rtb_hardlimit)
@@ -298,8 +301,11 @@ report_mount(
 	uint		qflags;
 	int		count;
 
-	if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0)
+	if (xfsquotactl(XFS_GETQUOTA, dev, type, id, (void *)&d) < 0) {
+		if (errno != ENOENT && errno != ENOSYS)
+			perror("XFS_GETQUOTA");
 		return 0;
+	}
 
 	if (flags & TERSE_FLAG) {
 		count = 0;
@@ -514,8 +520,10 @@ report_any_type(
 	if (type & XFS_USER_QUOTA) {
 		fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
 		while ((mount = fs_cursor_next_entry(&cursor))) {
-			xfsquotactl(XFS_QSYNC, mount->fs_name,
-						XFS_USER_QUOTA, 0, NULL);
+			if (xfsquotactl(XFS_QSYNC, mount->fs_name,
+						XFS_USER_QUOTA, 0, NULL) < 0
+					&& errno != ENOENT && errno != ENOSYS)
+				perror("XFS_QSYNC user quota");
 			report_user_mount(fp, form, mount,
 						lower, upper, flags);
 		}
@@ -523,8 +531,10 @@ report_any_type(
 	if (type & XFS_GROUP_QUOTA) {
 		fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
 		while ((mount = fs_cursor_next_entry(&cursor))) {
-			xfsquotactl(XFS_QSYNC, mount->fs_name,
-						XFS_GROUP_QUOTA, 0, NULL);
+			if (xfsquotactl(XFS_QSYNC, mount->fs_name,
+						XFS_GROUP_QUOTA, 0, NULL) < 0
+					&& errno != ENOENT && errno != ENOSYS)
+				perror("XFS_QSYNC group quota");
 			report_group_mount(fp, form, mount,
 						lower, upper, flags);
 		}
@@ -532,8 +542,10 @@ report_any_type(
 	if (type & XFS_PROJ_QUOTA) {
 		fs_cursor_initialise(dir, FS_MOUNT_POINT, &cursor);
 		while ((mount = fs_cursor_next_entry(&cursor))) {
-			xfsquotactl(XFS_QSYNC, mount->fs_name,
-						XFS_PROJ_QUOTA, 0, NULL);
+			if (xfsquotactl(XFS_QSYNC, mount->fs_name,
+						XFS_PROJ_QUOTA, 0, NULL) < 0
+					&& errno != ENOENT && errno != ENOSYS)
+				perror("XFS_QSYNC proj quota");
 			report_project_mount(fp, form, mount,
 						lower, upper, flags);
 		}
-- 
1.6.0.5




More information about the xfs mailing list