From: guangyu <guangyu.sun@oracle.com>
To: xfs@oss.sgi.com
Cc: Koen De Wit <koen.de.wit@oracle.com>
Subject: Re: [PATCH] xfsprogs: properly check size arguments for growfs
Date: Thu, 14 Nov 2013 11:59:17 -0800 [thread overview]
Message-ID: <20131114195916.GF6628@guasun> (raw)
In-Reply-To: <1384458608-16056-1-git-send-email-guangyu.sun@oracle.com>
On Thu, Nov 14, 2013 at 11:50:08AM -0800, Guangyu Sun wrote:
> xfs_growfs has lowercase options to grow a filesystem as big as possible
> (e.g. the -d option) and uppercase options to grow a filesystem to a
> specified size, expressed in blocks. (e.g. the "-D size" option)
>
> If the size parameter is not numerical, the parameter is either trimmed or
> ignored. In the latter case, the filesystem is grown as big as possible. This
> may happen when users accidentally specify the size in a format similar to
> mkfs.xfs (e.g. "-D 100m" or "-D size=16384")
>
> In both cases, xfs_growfs should return an error instead of resizing the
> filesystem.
>
> To reproduce:
> # mkfs.xfs -f -d size=20m -L koenfs /dev/dm-3
> # mount /dev/dm-3 //mnt
> # xfs_growfs -D 10000andmorethan10invalidcharacters /mnt
> (...)
> data blocks changed from 5120 to 10000
> # xfs_growfs -D invalidargument20000containingnumbers /mnt
> (...)
> data blocks changed from 10000 to 19659543
>
> Reported-by: Koen De Wit <koen.de.wit@oracle.com>
> Signed-off-by: Guangyu Sun <guangyu.sun@oracle.com>
> ---
> growfs/xfs_growfs.c | 22 +++++++++++++++++++---
> 1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/growfs/xfs_growfs.c b/growfs/xfs_growfs.c
> index 2df68fb..4ed8eb8 100644
> --- a/growfs/xfs_growfs.c
> +++ b/growfs/xfs_growfs.c
> @@ -123,6 +123,7 @@ main(int argc, char **argv)
> int projid32bit;
> int crcs_enabled;
> int ftype_enabled = 0;
> + char *endptr;
>
> progname = basename(argv[0]);
> setlocale(LC_ALL, "");
> @@ -137,7 +138,12 @@ main(int argc, char **argv)
> while ((c = getopt(argc, argv, "dD:e:ilL:m:np:rR:t:xV")) != EOF) {
> switch (c) {
> case 'D':
> - dsize = strtoll(optarg, NULL, 10);
> + dsize = strtoll(optarg, &endptr, 10);
> + if (endptr) {
> + fprintf(stderr, _("%s: %s is not a valid "
> + "number\n"), progname, optarg);
> + return 1;
> + }
> /* fall through */
> case 'd':
> dflag = 1;
> @@ -150,7 +156,12 @@ main(int argc, char **argv)
> lflag = iflag = 1;
> break;
> case 'L':
> - lsize = strtoll(optarg, NULL, 10);
> + lsize = strtoll(optarg, &endptr, 10);
> + if (endptr) {
> + fprintf(stderr, _("%s: %s is not a valid "
> + "number\n"), progname, optarg);
> + return 1;
> + }
> /* fall through */
> case 'l':
> lflag = 1;
> @@ -166,7 +177,12 @@ main(int argc, char **argv)
> progname = optarg;
> break;
> case 'R':
> - rsize = strtoll(optarg, NULL, 10);
> + rsize = strtoll(optarg, &endptr, 10);
> + if (endptr) {
> + fprintf(stderr, _("%s: %s is not a valid "
> + "number\n"), progname, optarg);
> + return 1;
> + }
> /* fall through */
> case 'r':
> rflag = 1;
> --
> 1.7.9.5
>
There is a typo in this patch. Will send v2 shortly.
Guangyu
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2013-11-14 19:59 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 19:50 [PATCH] xfsprogs: properly check size arguments for growfs Guangyu Sun
2013-11-14 19:59 ` guangyu [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=20131114195916.GF6628@guasun \
--to=guangyu.sun@oracle.com \
--cc=koen.de.wit@oracle.com \
--cc=xfs@oss.sgi.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