erofs-utils: lib: fix erofs_pack_file_from_fd()
PATCH 1/1 erofs-utils: lib: fix erofs_pack_file_from_fd()
If sendfile() fails, it should fall back to a plain copy.
Coverity-id: 554788
Fixes 84bae6acdbee ("erofs-utils: lib: keep full data until the fragment is committed")
Signed-off-by Gao Xiang <[email protected]>
--- lib/fragments.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
lib/fragments.c +4 -1
@@ -242,6 +242,9 @@ int erofs_pack_file_from_fd(struct erofs_inode *inode, int fd, u32 tofh)char *memblock;bool onheap = false; +if (__erofs_unlikely (!inode->i_size)) +return 0 ; + offset =lseek (epi->fd,0 ,SEEK_CUR );if (offset <0 )return -errno;
@@ -256,7 +259,7 @@ int erofs_pack_file_from_fd(struct erofs_inode *inode, int fd, u32 tofh) sz =min_t (u64, remaining,UINT_MAX ); rc =sendfile (epi->fd, fd,NULL , sz);if (rc <0 ) - goto out; +break ; remaining -= rc; }while (remaining);#endif
Signature · 1 line
2.43.5