public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@sandeen.net>
To: Bill O'Donnell <billodo@redhat.com>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH v3] xfsprogs: xfs_quota command error message improvement
Date: Wed, 24 Jun 2020 15:04:18 -0500	[thread overview]
Message-ID: <99f8230a-3048-daec-60af-e95f455a2878@sandeen.net> (raw)
In-Reply-To: <20200624154626.197456-1-billodo@redhat.com>

On 6/24/20 10:46 AM, 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>
> ---
> 
> v3: remove EINVAL case from the OFF case
> v2: enable internationalization and capitalize new message strings
> 
>  quota/state.c | 31 +++++++++++++++++++++++++------
>  1 file changed, 25 insertions(+), 6 deletions(-)
> 
> diff --git a/quota/state.c b/quota/state.c
> index 8f9718f1..76b6ceda 100644
> --- a/quota/state.c
> +++ b/quota/state.c
> @@ -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,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)
> +			fprintf(stderr, _("Quota already off.\n"));
> +		else
> +			perror("XFS_QUOTAOFF");
> +	}

Hm...

# mount -o quota /dev/pmem0p1 /mnt/test
# xfs_quota -x -c "off" /mnt/test
# xfs_quota -x -c "off" /mnt/test
XFS_QUOTAOFF: Function not implemented

If the last quota type is turned off, I guess we get ENOSYS.

Until then, we get EEXIST, as you handle above. i.e. if I mount with all 3 quota types:

# mount -o gquota -o uquota -opquota /dev/pmem0p1 /mnt/test
# xfs_quota -x -c off /mnt/test
# xfs_quota -x -c off /mnt/test
Quota already off.
# xfs_quota -x -c "off -g" /mnt/test
# xfs_quota -x -c "off -g" /mnt/test
Quota already off.
# xfs_quota -x -c "off -p" /mnt/test
# xfs_quota -x -c "off -p" /mnt/test
XFS_QUOTAOFF: Function not implemented

we can see the difference.  So this might need a bit more logic (and probably some
kernel code reading?) to make things consistent.

-Eric

      reply	other threads:[~2020-06-24 20:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 15:46 [PATCH v3] xfsprogs: xfs_quota command error message improvement Bill O'Donnell
2020-06-24 20:04 ` Eric Sandeen [this message]

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=99f8230a-3048-daec-60af-e95f455a2878@sandeen.net \
    --to=sandeen@sandeen.net \
    --cc=billodo@redhat.com \
    --cc=linux-xfs@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox