xfsprogs: xfs_quota command error message improvement
PATCH v2 1/1 xfsprogs: xfs_quota command error message improvement
Make the error messages for rudimentary xfs_quota commands (off, enable, disable) more user friendly, instead of the terse sys error outputs.
---
v2: enable internationalization and capitalize new message strings.
quota/state.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)
quota/state.c +28 -6
@@ -306,8 +306,15 @@ enable_enforcement(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAON , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAON" ); +if (xfsquotactl (XFS_QUOTAON , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr,_ ("Quota enforcement already enabled.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't enable when quotas are off.\n" )); +else +perror ("XFS_QUOTAON" ); + }else if (flags &VERBOSE_FLAG )state_quotafile_mount (stdout, type, mount, flags); }
@@ -328,8 +335,16 @@ disable_enforcement(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAOFF" ); +if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr, +_ ("Quota enforcement already disabled.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't disable when quotas are off.\n" )); +else +perror ("XFS_QUOTAOFF" ); + }else if (flags &VERBOSE_FLAG )state_quotafile_mount (stdout, type, mount, flags); }
@@ -350,8 +365,15 @@ quotaoff(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAOFF" ); +if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr,_ ("Quota already off.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't disable when quotas are off.\n" )); +else +perror ("XFS_QUOTAOFF" ); + }else if (flags &VERBOSE_FLAG )state_quotafile_mount (stdout, type, mount, flags); }
Signature · 1 line
2.26.2
Quoted 5 lines · Bill O'Donnell
Make the error messages for rudimentary
xfs_quotacommands (off, enable, disable) more user friendly, instead of the terse sys error outputs.Signed-off-by Bill O'Donnell <[email protected]>
Yay, another sharp edge smoothed down,
--D
Quoted 69 lines
---
v2: enable internationalization and capitalize new message strings.
quota/state.c | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-)quota/state.c +28
-6@@ -306,8 +306,15 @@ enable_enforcement(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAON , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAON" ); +if (xfsquotactl (XFS_QUOTAON , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr,_ ("Quota enforcement already enabled.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't enable when quotas are off.\n" )); +else +perror ("XFS_QUOTAON" ); + }else if (flags &VERBOSE_FLAG )state_quotafile_mount (stdout, type, mount, flags); }@@ -328,8 +335,16 @@ disable_enforcement(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAOFF" ); +if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr, +_ ("Quota enforcement already disabled.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't disable when quotas are off.\n" )); +else +perror ("XFS_QUOTAOFF" ); + }else if (flags &VERBOSE_FLAG )state_quotafile_mount (stdout, type, mount, flags); }@@ -350,8 +365,15 @@ quotaoff(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAOFF" ); +if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr,_ ("Quota already off.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't disable when quotas are off.\n" )); +else +perror ("XFS_QUOTAOFF" ); + }else if (flags &VERBOSE_FLAG )state_quotafile_mount (stdout, type, mount, flags); }Signature · 1 line
2.26.2
quota/state.c quotaoff( · line 373
Quoted 12 lines · Bill O'Donnell
quota/state.c +6
-2@@ -350,8 +365,15 @@ quotaoff(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAOFF" ); +if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr,_ ("Quota already off.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't disable when quotas are off.\n" ));
Is this the right message here? We get here from off_f(), which disables enforcement and accounting, so I'm not sure "can't disable" makes sense if "disable" means "disable enforcement" as it did in disable_enforcement()...?
(IOWs, have can you provoke EINVAL? How? Sorry, this just kind of jumps out at me because "can't disable" seems a little out of place in quotaoff() so I want to double check.)
Thanks,
-Eric
Quoted 18 lines · Eric Sandeen
quota/state.c quotaoff( · line 373
Quoted 12 lines · Bill O'Donnell
quota/state.c +6
-2@@ -350,8 +365,15 @@ quotaoff(return ; } dir = mount->fs_name; -if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) -perror ("XFS_QUOTAOFF" ); +if (xfsquotactl (XFS_QUOTAOFF , dir, type,0 , (void *)&qflags) <0 ) { +if (errno ==EEXIST ) +fprintf (stderr,_ ("Quota already off.\n" )); +else if (errno ==EINVAL ) +fprintf (stderr, +_ ("Can't disable when quotas are off.\n" ));Is this the right message here? We get here from
off_f(), which disables enforcement and accounting, so I'm not sure "can't disable" makes sense if "disable" means "disable enforcement" as it did indisable_enforcement()...?
Quoted 3 lines
(IOWs, have can you provoke EINVAL? How? Sorry, this just kind of jumps out at me because "can't disable" seems a little out of place in
quotaoff()so I want to double check.)
You're right. It was a copy/paste from the disable case. You also have a good point in that I don't think EINVAL is ever provoked for the OFF case. I'll recheck it.
Thanks-
Bill
Quoted 4 lines
Thanks,
-Eric