struct options opt = {
.o_copy_attrs = 1,
.o_shadow_tree = 1,
- .o_verbose = LLAPI_MSG_WARN,
+ .o_verbose = LLAPI_MSG_INFO,
.o_copy_xattrs = 1,
.o_report_int = REPORT_INTERVAL_DEFAULT,
.o_chunk_size = ONE_MB,
return rc;
}
- rc = lseek(src_fd, hai->hai_extent.offset, SEEK_SET);
- if (rc < 0) {
- CT_ERROR(errno,
- "cannot seek for read to "LPU64" (len %jd) in '%s'",
- hai->hai_extent.offset, (intmax_t)src_st.st_size, src);
- rc = -errno;
- goto out;
- }
-
if (fstat(dst_fd, &dst_st) < 0) {
CT_ERROR(errno, "cannot stat '%s'", dst);
return -errno;
return rc;
}
+ rc = lseek(src_fd, hai->hai_extent.offset, SEEK_SET);
+ if (rc < 0) {
+ CT_ERROR(errno,
+ "cannot seek for read to "LPU64" (len %jd) in '%s'",
+ hai->hai_extent.offset, (intmax_t)src_st.st_size, src);
+ rc = -errno;
+ goto out;
+ }
+
rc = lseek(dst_fd, hai->hai_extent.offset, SEEK_SET);
if (rc < 0) {
rc = -errno;
errno = 0;
/* Don't read beyond a given extent */
- rlen = (hai->hai_extent.length == -1LL) ?
- src_st.st_size : hai->hai_extent.length;
+ rlen = min(hai->hai_extent.length, src_st.st_size);
+
+ CT_DEBUG("Going to copy "LPU64" bytes %s -> %s\n", rlen, src, dst);
while (wpos < rlen) {
int chunk = (rlen - wpos > opt.o_chunk_size) ?
{
struct hsm_copyaction_private *hcp = NULL;
char src[PATH_MAX];
- char dst[PATH_MAX];
+ char dst[PATH_MAX] = "";
int rc;
int rcf = 0;
bool rename_needed = false;
}
}
+ setbuf(stdout, NULL);
+
rc = llapi_hsm_copytool_register(&ctdata, opt.o_mnt, 0,
opt.o_archive_cnt, opt.o_archive_id);
if (rc < 0) {