From: Zorro Lang <zlang@redhat.com>
To: "Jianhong.Yin" <yin-jianhong@163.com>
Cc: linux-xfs@vger.kernel.org, jiyin@redhat.com
Subject: Re: [PATCH 2/2] xfsprogs: copy_range: let = (src_size - src_offset) if len omitted
Date: Thu, 5 Sep 2019 14:01:32 +0800 [thread overview]
Message-ID: <20190905060131.GB7239@dhcp-12-102.nay.redhat.com> (raw)
In-Reply-To: <20190905053152.15701-2-yin-jianhong@163.com>
On Thu, Sep 05, 2019 at 01:31:52PM +0800, Jianhong.Yin wrote:
> add update man page.
>
> Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
> ---
I think these can be in one patch, but anyway...
> io/copy_file_range.c | 7 +++++--
> man/man8/xfs_io.8 | 9 +++------
> 2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/io/copy_file_range.c b/io/copy_file_range.c
> index 283f5094..02d50e53 100644
> --- a/io/copy_file_range.c
> +++ b/io/copy_file_range.c
> @@ -72,6 +72,7 @@ copy_range_f(int argc, char **argv)
> long long src = 0;
> long long dst = 0;
> size_t len = 0;
> + int len_ommited = 1;
> int opt;
> int ret;
> int fd;
> @@ -103,6 +104,7 @@ copy_range_f(int argc, char **argv)
> printf(_("invalid length -- %s\n"), optarg);
> return 0;
> }
> + len_ommited = 0;
> break;
> case 'f':
> src_file_nr = atoi(argv[1]);
> @@ -128,7 +130,7 @@ copy_range_f(int argc, char **argv)
> fd = filetable[src_file_nr].fd;
> }
>
> - if (src == 0 && dst == 0 && len == 0) {
> + if (len_ommited) {
> off64_t sz;
>
> sz = copy_src_filesize(fd);
> @@ -136,7 +138,8 @@ copy_range_f(int argc, char **argv)
> ret = 1;
> goto out;
> }
> - len = sz;
> + if (sz > src)
> + len = sz - src;
What about file size < offset?
Maybe we can do like this?:
sz = copy_src_filesize(fd);
if (sz < 0 || (unsigned long long)sz > SIZE_MAX || sz < src) {
ret = 1;
goto out;
}
len = sz - src;
Thanks,
Zorro
> }
>
> ret = copy_file_range_cmd(fd, &src, &dst, len);
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index 6e064bdd..f5f1c4fc 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -669,13 +669,10 @@ The source must be specified either by path
> or as another open file
> .RB ( \-f ).
> If
> -.I src_file
> -.IR src_offset ,
> -.IR dst_offset ,
> -and
> .I length
> -are omitted the contents of src_file will be copied to the beginning of the
> -open file, overwriting any data already there.
> +is omitted will use
> +.I src_file
> +(file size - src_offset) instead.
> .RS 1.0i
> .PD 0
> .TP 0.4i
> --
> 2.21.0
>
next prev parent reply other threads:[~2019-09-05 5:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-05 5:31 [PATCH 1/2] xfsprogs: copy_range don't truncate dstfile Jianhong.Yin
2019-09-05 5:31 ` [PATCH 2/2] xfsprogs: copy_range: let = (src_size - src_offset) if len omitted Jianhong.Yin
2019-09-05 6:01 ` Zorro Lang [this message]
2019-09-05 6:04 ` Jianhong Yin
2019-09-05 8:13 ` Zorro Lang
2019-09-06 0:53 ` Zorro Lang
2019-09-06 2:18 ` Jianhong Yin
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=20190905060131.GB7239@dhcp-12-102.nay.redhat.com \
--to=zlang@redhat.com \
--cc=jiyin@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=yin-jianhong@163.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;
as well as URLs for NNTP newsgroup(s).