[PATCH 11/20] xfs_quota: Dont ignore every error when asking for quota

Christoph Hellwig
2008-12-22T16:44:10Z

[-- Attachment #1: xfsprogs-quota-dont-ignore-all-errors --]
[-- Type: text/plain, Size: 3309 bytes --]

From: Arkadiusz Miskiewicz <arekm@maven.pl>

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.

Reviewed-by: Christoph Hellwig <hch@lst.de>

---
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