Skip to content
Snippets Groups Projects
Commit 26375b53 authored by Colin Walters's avatar Colin Walters
Browse files

Merge branch 'pr/ficlone-fixes' into 'master'

fdio: fix fd offset handling with `FICLONE`

See merge request GNOME/libglnx!41
parents c59eb271 7a2f26a3
No related branches found
No related tags found
1 merge request!504Update libglnx
......@@ -794,10 +794,21 @@ glnx_regfile_copy_bytes (int fdf, int fdt, off_t max_bytes)
/* If we've requested to copy the whole range, try a full-file clone first.
*/
if (max_bytes == (off_t) -1)
if (max_bytes == (off_t) -1 &&
lseek (fdf, 0, SEEK_CUR) == 0 &&
lseek (fdt, 0, SEEK_CUR) == 0)
{
if (ioctl (fdt, FICLONE, fdf) == 0)
return 0;
{
/* All the other methods advance the fds. Do it here too for consistency. */
if (lseek (fdf, 0, SEEK_END) < 0)
return -1;
if (lseek (fdt, 0, SEEK_END) < 0)
return -1;
return 0;
}
/* Fall through */
struct stat stbuf;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment