public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Wang Yugui <wangyugui@e16-tech.com>
To: linux-btrfs@vger.kernel.org
Cc: Sidong Yang <realwakka@gmail.com>
Subject: Re: [PATCH] btrfs-progs: fi resize: fix return value check_resize_args()
Date: Mon, 12 Sep 2022 15:58:47 +0800	[thread overview]
Message-ID: <20220912155843.F86F.409509F4@e16-tech.com> (raw)
In-Reply-To: <20220811152239.2845-1-realwakka@gmail.com>

Hi,

> check_resize_args() function checks user argument amount and should
> returns it's validity. But now the code returns only zero. This patch
> make it correct to return ret.
> 
> Signed-off-by: Sidong Yang <realwakka@gmail.com>
> ---
>  cmds/filesystem.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cmds/filesystem.c b/cmds/filesystem.c
> index 7cd08fcd..9eff5680 100644
> --- a/cmds/filesystem.c
> +++ b/cmds/filesystem.c
> @@ -1203,7 +1203,7 @@ static int check_resize_args(const char *amount, const char *path) {
>  
>  out:
>  	free(di_args);
> -	return 0;
> +	return ret;
>  }
>  
>  static int cmd_filesystem_resize(const struct cmd_struct *cmd,

This patch will make 'btrfs filesystem resize' always fail, and then break
fstests btrfs/177.

# df -h /mnt/scratch/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2       1.0G  3.4M  927M   1% /mnt/scratch

# btrfs filesystem resize 3G /mnt/scratch/
Resize device id 1 (/dev/sdb2) from 3.00GiB to 3.00GiB
# echo $?
1

# df -h /mnt/scratch/
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb2       1.0G  3.4M  927M   1% /mnt/scratch


'ret' is set to 2 here.
    ret = snprintf(amount_dup, BTRFS_VOL_NAME_MAX, "%s", amount);
    if (strlen(amount) != ret) {
        error("newsize argument is too long");
        ret = 1;
        goto out;
    }

Best Regards
Wang Yugui (wangyugui@e16-tech.com)
2022/09/12



  parent reply	other threads:[~2022-09-12  7:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-11 15:22 [PATCH] btrfs-progs: fi resize: fix return value check_resize_args() Sidong Yang
2022-08-23 20:42 ` David Sterba
2022-09-12  7:58 ` Wang Yugui [this message]
2022-09-12 12:34   ` David Sterba

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=20220912155843.F86F.409509F4@e16-tech.com \
    --to=wangyugui@e16-tech.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=realwakka@gmail.com \
    /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