All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: "Bill O'Donnell" <billodo@redhat.com>
Cc: linux-xfs@vger.kernel.org, sandeen@sandeen.net
Subject: Re: [PATCH 1/3] xfsprogs: xfs_quota command error message improvement
Date: Fri, 17 Jul 2020 14:10:55 -0700	[thread overview]
Message-ID: <20200717211055.GR3151642@magnolia> (raw)
In-Reply-To: <20200715201253.171356-2-billodo@redhat.com>

On Wed, Jul 15, 2020 at 03:12:51PM -0500, Bill O'Donnell wrote:
> Make the error messages for rudimentary xfs_quota commands
> (off, enable, disable) more user friendly, instead of the
> terse sys error outputs.
> 
> Signed-off-by: Bill O'Donnell <billodo@redhat.com>

Hmmm... where are the underlying ioctls documented, anyways?
Can we please get that done?

(Note that ENOSYS can also mean that the fs didn't register any quota
operations, but xfs always does so meh.)

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  quota/state.c | 32 ++++++++++++++++++++++++++------
>  1 file changed, 26 insertions(+), 6 deletions(-)
> 
> diff --git a/quota/state.c b/quota/state.c
> index 8f9718f1..7a595fc6 100644
> --- a/quota/state.c
> +++ b/quota/state.c
> @@ -306,8 +306,16 @@ 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 || errno == ENOSYS)
> +			fprintf(stderr,
> +				_("Can't enable enforcement when quota off.\n"));
> +		else
> +			perror("XFS_QUOTAON");
> +	}
>  	else if (flags & VERBOSE_FLAG)
>  		state_quotafile_mount(stdout, type, mount, flags);
>  }
> @@ -328,8 +336,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 || errno == ENOSYS)
> +			fprintf(stderr,
> +				_("Can't disable enforcement when quota off.\n"));
> +		else
> +			perror("XFS_QUOTAOFF");
> +	}
>  	else if (flags & VERBOSE_FLAG)
>  		state_quotafile_mount(stdout, type, mount, flags);
>  }
> @@ -350,8 +366,12 @@ 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 || errno == ENOSYS)
> +			fprintf(stderr, _("Quota already off.\n"));
> +		else
> +			perror("XFS_QUOTAOFF");
> +	}
>  	else if (flags & VERBOSE_FLAG)
>  		state_quotafile_mount(stdout, type, mount, flags);
>  }
> -- 
> 2.26.2
> 

  reply	other threads:[~2020-07-17 21:11 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-15 20:12 [PATCH 0/3] xfsprogs: xfs_quota error message and state reporting improvement Bill O'Donnell
2020-07-15 20:12 ` [PATCH 1/3] xfsprogs: xfs_quota command error message improvement Bill O'Donnell
2020-07-17 21:10   ` Darrick J. Wong [this message]
2020-07-21 15:04   ` Christoph Hellwig
2020-07-21 15:55     ` Bill O'Donnell
2020-07-15 20:12 ` [PATCH 2/3] xfs_quota: display warning limits when printing quota type information Bill O'Donnell
2020-07-15 20:12 ` [PATCH 3/3] xfsprogs: xfs_quota state command should report ugp grace times Bill O'Donnell
2020-07-15 20:33   ` Eric Sandeen
2020-07-15 20:44     ` Bill O'Donnell
2020-07-17 20:43   ` [PATCH v2 " Bill O'Donnell
2020-07-17 21:13     ` Darrick J. Wong
2020-07-21 15:05     ` Christoph Hellwig
2020-07-30 17:46 ` [PATCH 0/3] xfsprogs: xfs_quota error message and state reporting improvement Eric Sandeen
2020-07-30 17:52   ` Bill O'Donnell
2020-07-30 18:30     ` Eric Sandeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200717211055.GR3151642@magnolia \
    --to=darrick.wong@oracle.com \
    --cc=billodo@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.