linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: Yangtao Li <frank.li@vivo.com>, jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs_io: expend fallocate command
Date: Wed, 17 May 2023 09:53:35 +0800	[thread overview]
Message-ID: <f5cd52e3-802a-f36c-ebe5-647875c355c3@kernel.org> (raw)
In-Reply-To: <20230506114537.49470-2-frank.li@vivo.com>

On 2023/5/6 19:45, Yangtao Li wrote:
> Expend fallocate command to support more flags.
> 
> Signed-off-by: Yangtao Li <frank.li@vivo.com>
> ---
>   tools/f2fs_io/f2fs_io.c | 37 ++++++++++++++++++++++++++++++++-----
>   1 file changed, 32 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
> index 126e1f9..1be8c9e 100644
> --- a/tools/f2fs_io/f2fs_io.c
> +++ b/tools/f2fs_io/f2fs_io.c
> @@ -416,6 +416,10 @@ static void do_pinfile(int argc, char **argv, const struct cmd_desc *cmd)
>   "f2fs_io fallocate [keep_size] [offset] [length] [file]\n\n"	\

It needs to update above description, and manual as well?

f2fs_io fallocate [-cipz] [keep_size] [offset] [length] [file]

Thanks,

>   "fallocate given the file\n"					\
>   " [keep_size] : 1 or 0\n"					\
> +" -p : punch hole\n"						\
> +" -c : collapse range\n"					\
> +" -z : zero range\n"						\
> +" -i : insert range\n"						\
>   
>   static void do_fallocate(int argc, char **argv, const struct cmd_desc *cmd)
>   {
> @@ -423,20 +427,43 @@ static void do_fallocate(int argc, char **argv, const struct cmd_desc *cmd)
>   	off_t offset, length;
>   	struct stat sb;
>   	int mode = 0;
> +	int c;
>   
> -	if (argc != 5) {
> +	while ((c = getopt(argc, argv, "cipz")) != -1) {
> +		switch (c) {
> +		case 'c':
> +			mode |= FALLOC_FL_COLLAPSE_RANGE;
> +			break;
> +		case 'i':
> +			mode |= FALLOC_FL_INSERT_RANGE;
> +			break;
> +		case 'p':
> +			mode |= FALLOC_FL_PUNCH_HOLE;
> +			break;
> +		case 'z':
> +			mode |= FALLOC_FL_ZERO_RANGE;
> +			break;
> +		default:
> +			fputs(cmd->cmd_help, stderr);
> +			exit(2);
> +		}
> +	}
> +	argc -= optind;
> +	argv += optind;
> +
> +	if (argc != 4) {
>   		fputs("Excess arguments\n\n", stderr);
>   		fputs(cmd->cmd_help, stderr);
>   		exit(1);
>   	}
>   
> -	if (!strcmp(argv[1], "1"))
> +	if (!strcmp(argv[0], "1"))
>   		mode |= FALLOC_FL_KEEP_SIZE;
>   
> -	offset = atoi(argv[2]);
> -	length = atoll(argv[3]);
> +	offset = atoi(argv[1]);
> +	length = atoll(argv[2]);
>   
> -	fd = xopen(argv[4], O_RDWR, 0);
> +	fd = xopen(argv[3], O_RDWR, 0);
>   
>   	if (fallocate(fd, mode, offset, length) != 0)
>   		die_errno("fallocate failed");


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

  reply	other threads:[~2023-05-17  1:53 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-06 11:45 [f2fs-dev] [PATCH v2] f2fs_io: support move_range command Yangtao Li via Linux-f2fs-devel
2023-05-06 11:45 ` [f2fs-dev] [PATCH] f2fs_io: expend fallocate command Yangtao Li via Linux-f2fs-devel
2023-05-17  1:53   ` Chao Yu [this message]
2023-05-17  1:41 ` [f2fs-dev] [PATCH v2] f2fs_io: support move_range command Chao Yu

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=f5cd52e3-802a-f36c-ebe5-647875c355c3@kernel.org \
    --to=chao@kernel.org \
    --cc=frank.li@vivo.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).