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 <hsiang...@linux.alibaba.com> --- lib/fragments.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/fragments.c b/lib/fragments.c index d63995e..e65963b 100644 --- a/lib/fragments.c +++ b/lib/fragments.c @@ -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 -- 2.43.5