All of lore.kernel.org
 help / color / mirror / Atom feed
* An question for FICLONERANGE ioctl
@ 2021-09-05 12:14 Sidong Yang
  2021-09-06  1:13 ` Qu Wenruo
  0 siblings, 1 reply; 5+ messages in thread
From: Sidong Yang @ 2021-09-05 12:14 UTC (permalink / raw)
  To: linux-btrfs

Hi, All.
I've tried to handle btrfs-progs issue.
(https://github.com/kdave/btrfs-progs/issues/396)

And I tested some code like below.

src_fd = open(src_path, O_RDONLY);
if (src_fd < 0) {
	error("cannot open src path %s", src_path);
	return 1;
}

dest_fd = open(dest_path, O_WRONLY|O_CREAT, 0666);
if (dest_fd < 0) {
    close(src_fd);
    error("cannot open dest path %s", dest_path);
    return 1;
}

range.src_fd = src_fd;
range.src_offset = src_offset;
range.src_length = length;
range.dest_offset = dest_offset;

ret = ioctl(dest_fd, FICLONERANGE, &range);

And this ioctl call failed with error code invalid arguments when length!=0.
I tried to understand FICLONERANGE man page but I think there is no clue
about this. I traced kernel code and found out it goes fail in
generic_remap_checks(). There is an condition checks if req_count is
correct size and it makes test code fails. 

I don't know about this condition but it seems that it can be passed for
setting REMAP_FILE_CAN_SHORTEN. Is there any way to setting remap_flags
in FICLONERANGE ioctl call?

Also it would be pleased that if you provide some documentation about
this.

Sorry for writing without thinking deeply.

Thanks,
Sidong

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-06 10:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-05 12:14 An question for FICLONERANGE ioctl Sidong Yang
2021-09-06  1:13 ` Qu Wenruo
2021-09-06  5:57   ` Sidong Yang
2021-09-06  6:30     ` Qu Wenruo
2021-09-06 10:21       ` Sidong Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.