summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/logic/tpax_archive_write.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/logic/tpax_archive_write.c b/src/logic/tpax_archive_write.c
index 2555d26..1a641bf 100644
--- a/src/logic/tpax_archive_write.c
+++ b/src/logic/tpax_archive_write.c
@@ -79,7 +79,9 @@ static int tpax_archive_write_impl(
{
struct tpax_unit_ctx * uctx;
struct tpax_ustar_header uhdr;
+ const struct stat * st;
const char * path;
+ const char * slnk;
off_t hpos;
off_t dpos;
int fdtmp;
@@ -100,6 +102,9 @@ static int tpax_archive_write_impl(
if (tpax_lib_get_unit_ctx(dctx,fdcwd,path,&uctx) < 0)
return TPAX_NESTED_ERROR(dctx);
+ st = uctx->st;
+ slnk = uctx->link[0];
+
/* record errors */
tpax_driver_set_ectx(
dctx,0,path);
@@ -110,8 +115,8 @@ static int tpax_archive_write_impl(
/* header */
if (tpax_meta_init_ustar_header(
- dctx,path,uctx->st,
- *uctx->link,&uhdr) < 0)
+ dctx,path,st,
+ slnk,&uhdr) < 0)
return tpax_archive_write_ret(
TPAX_NESTED_ERROR(dctx),
uctx);
@@ -121,25 +126,25 @@ static int tpax_archive_write_impl(
fdtmp = -1;
/* associated data? */
- if S_ISREG(uctx->st->st_mode) {
+ if S_ISREG(st->st_mode) {
buf = tpax_get_driver_anon_map_addr(
dctx,&buflen);
- if (buflen >= (cmplen = uctx->st->st_size))
+ if (buflen >= (cmplen = st->st_size))
membuf = buf;
/* snapshot */
if (membuf) {
if (tpax_io_create_memory_snapshot(
dctx,fdcwd,path,
- uctx->st,membuf) < 0)
+ st,membuf) < 0)
return tpax_archive_write_ret(
TPAX_NESTED_ERROR(dctx),
uctx);
} else {
if ((fdtmp = tpax_io_create_tmpfs_snapshot(
dctx,fdcwd,path,
- uctx->st)) < 0)
+ st)) < 0)
return tpax_archive_write_ret(
TPAX_NESTED_ERROR(dctx),
uctx);
@@ -164,7 +169,7 @@ static int tpax_archive_write_impl(
tpax_set_driver_cpos(dctx,dpos);
/* all done? */
- if (!(S_ISREG(uctx->st->st_mode))) {
+ if (!(S_ISREG(st->st_mode))) {
tpax_lib_free_unit_ctx(uctx);
return 0;
}
@@ -174,7 +179,7 @@ static int tpax_archive_write_impl(
buf = tpax_get_driver_anon_map_addr(
dctx,&buflen);
- for (nread=0; nread<uctx->st->st_size; ) {
+ for (nread=0; nread<st->st_size; ) {
nbytes = read(fdtmp,buf,buflen);
while ((nbytes < 0) && (errno == EINTR))
@@ -208,14 +213,14 @@ static int tpax_archive_write_impl(
} else {
if (tpax_archive_append_memory_data(
fdout,membuf,
- uctx->st->st_size) < 0)
+ st->st_size) < 0)
return tpax_archive_write_ret(
TPAX_SYSTEM_ERROR(dctx),
uctx);
}
return tpax_archive_write_ret(
- tpax_archive_append_pad(dctx,fdout,uctx->st),
+ tpax_archive_append_pad(dctx,fdout,st),
uctx);
}