summaryrefslogtreecommitdiff
path: root/src/logic
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2024-06-09 00:23:34 +0000
committermidipix <writeonce@midipix.org>2024-06-09 00:41:58 +0000
commite99de36b4ab5f9f8a331b4a4401204a19c468957 (patch)
treea31f4bac44ee6fe25ffd0b7b432ab6f3873a6e7c /src/logic
parent25362d2365de0e6b24959c57f3a84e7a19b0b6a5 (diff)
downloadtpax-e99de36b4ab5f9f8a331b4a4401204a19c468957.tar.bz2
tpax-e99de36b4ab5f9f8a331b4a4401204a19c468957.tar.xz
driver: implemented and integrated the -v (verbose mode) cmdline option.
Diffstat (limited to 'src/logic')
-rw-r--r--src/logic/tpax_archive_write.c49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/logic/tpax_archive_write.c b/src/logic/tpax_archive_write.c
index 98d7dfc..7ce6cca 100644
--- a/src/logic/tpax_archive_write.c
+++ b/src/logic/tpax_archive_write.c
@@ -64,9 +64,13 @@ static int tpax_archive_append_pad(
}
static int tpax_archive_write_ret(
- int ret,
- struct tpax_unit_ctx * uctx)
+ int ret,
+ const struct tpax_driver_ctx * dctx,
+ struct tpax_unit_ctx * uctx)
{
+ if (dctx->cctx->drvflags & TPAX_DRIVER_VERBOSE)
+ tpax_dprintf(tpax_driver_fderr(dctx),"\n",0);
+
tpax_lib_free_unit_ctx(uctx);
return ret;
}
@@ -106,9 +110,15 @@ static int tpax_archive_write_impl(
dctx,
TPAX_ERR_FLOW_ERROR);
+ /* verbose mode */
+ if (dctx->cctx->drvflags & TPAX_DRIVER_VERBOSE)
+ tpax_dprintf(tpax_driver_fderr(dctx),"%s",path);
+
/* uctx */
if (tpax_lib_get_unit_ctx(dctx,fdcwd,path,&uctx) < 0)
- return TPAX_NESTED_ERROR(dctx);
+ tpax_archive_write_ret(
+ TPAX_NESTED_ERROR(dctx),
+ dctx,0);
st = uctx->st;
slnk = uctx->link[0];
@@ -126,7 +136,7 @@ static int tpax_archive_write_impl(
TPAX_CUSTOM_ERROR(
dctx,
TPAX_ERR_FLOW_ERROR),
- uctx);
+ dctx,uctx);
strcpy(pathbuf,path);
@@ -138,7 +148,7 @@ static int tpax_archive_write_impl(
TPAX_CUSTOM_ERROR(
dctx,
TPAX_ERR_FLOW_ERROR),
- uctx);
+ dctx,uctx);
if (ch) {
strcpy(ch,mlnk);
@@ -148,7 +158,7 @@ static int tpax_archive_write_impl(
if (fstatat(fdcwd,mlnk,&stbuf,0) < 0)
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
- uctx);
+ dctx,uctx);
}
/* record errors */
@@ -165,7 +175,7 @@ static int tpax_archive_write_impl(
slnk,&uhdr) < 0)
return tpax_archive_write_ret(
TPAX_NESTED_ERROR(dctx),
- uctx);
+ dctx,uctx);
/* buffer */
membuf = 0;
@@ -187,7 +197,7 @@ static int tpax_archive_write_impl(
st,membuf) < 0)
return tpax_archive_write_ret(
TPAX_NESTED_ERROR(dctx),
- uctx);
+ dctx,uctx);
} else {
if ((fdtmp = tpax_io_create_tmpfs_snapshot(
dctx,fdcwd,
@@ -195,12 +205,12 @@ static int tpax_archive_write_impl(
st)) < 0)
return tpax_archive_write_ret(
TPAX_NESTED_ERROR(dctx),
- uctx);
+ dctx,uctx);
if (lseek(fdtmp,0,SEEK_SET) < 0)
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
- uctx);
+ dctx,uctx);
}
}
@@ -211,16 +221,15 @@ static int tpax_archive_write_impl(
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
- uctx);
+ dctx,uctx);
}
tpax_set_driver_cpos(dctx,dpos);
/* all done? */
- if (!(S_ISREG(st->st_mode))) {
- tpax_lib_free_unit_ctx(uctx);
- return 0;
- }
+ if (!(S_ISREG(st->st_mode)))
+ return tpax_archive_write_ret(
+ 0,dctx,uctx);
/* append data from snapshot */
if (fdtmp >= 0) {
@@ -237,13 +246,13 @@ static int tpax_archive_write_impl(
close(fdtmp);
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
- uctx);
+ dctx,uctx);
} else if (nbytes == 0) {
close(fdtmp);
return tpax_archive_write_ret(
TPAX_CUSTOM_ERROR(dctx,TPAX_ERR_FLOW_ERROR),
- uctx);
+ dctx,uctx);
} else {
nread += nbytes;
@@ -253,7 +262,7 @@ static int tpax_archive_write_impl(
close(fdtmp);
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
- uctx);
+ dctx,uctx);
}
}
@@ -264,12 +273,12 @@ static int tpax_archive_write_impl(
st->st_size) < 0)
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
- uctx);
+ dctx,uctx);
}
return tpax_archive_write_ret(
tpax_archive_append_pad(dctx,fdout,st),
- uctx);
+ dctx,uctx);
}
int tpax_archive_write(const struct tpax_driver_ctx * dctx)