summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2020-05-31 18:19:48 +0000
committermidipix <writeonce@midipix.org>2020-05-31 18:34:52 +0000
commitaf498808d3ac418dc84be14e42cae054afa5bac6 (patch)
tree9a020d7f7627d9fb0467cf7d785f481db2f2e469 /src
parent800ed359ef4eb6169e2d167c082a16791b9c92fd (diff)
downloadtpax-af498808d3ac418dc84be14e42cae054afa5bac6.tar.bz2
tpax-af498808d3ac418dc84be14e42cae054afa5bac6.tar.xz
tpax_archive_append(): only create/write snapshots for regular files.
Diffstat (limited to 'src')
-rw-r--r--src/logic/tpax_archive_append.c49
1 files changed, 28 insertions, 21 deletions
diff --git a/src/logic/tpax_archive_append.c b/src/logic/tpax_archive_append.c
index dfdd92c..caa2606 100644
--- a/src/logic/tpax_archive_append.c
+++ b/src/logic/tpax_archive_append.c
@@ -114,27 +114,30 @@ int tpax_archive_append(
membuf = 0;
fdtmp = -1;
- if ((buf = tpax_get_driver_anon_map_addr(dctx,&buflen)))
- if (buflen >= (cmplen = uctx->st->st_size))
- membuf = buf;
-
- if (ssizeof(sbuf) >= (uctx->st->st_size))
- membuf = sbuf;
-
- /* snapshot */
- if (membuf) {
- if (tpax_file_create_memory_snapshot(
- dctx,*uctx->path,
- uctx->st,membuf) < 0)
- return TPAX_NESTED_ERROR(dctx);
- } else {
- if ((fdtmp = tpax_file_create_tmpfs_snapshot(
- dctx,*uctx->path,
- uctx->st)) < 0)
- return TPAX_NESTED_ERROR(dctx);
-
- if (lseek(fdtmp,0,SEEK_SET) < 0)
- return TPAX_SYSTEM_ERROR(dctx);
+ /* associated data? */
+ if S_ISREG(uctx->st->st_mode) {
+ if ((buf = tpax_get_driver_anon_map_addr(dctx,&buflen)))
+ if (buflen >= (cmplen = uctx->st->st_size))
+ membuf = buf;
+
+ if (ssizeof(sbuf) >= (uctx->st->st_size))
+ membuf = sbuf;
+
+ /* snapshot */
+ if (membuf) {
+ if (tpax_file_create_memory_snapshot(
+ dctx,*uctx->path,
+ uctx->st,membuf) < 0)
+ return TPAX_NESTED_ERROR(dctx);
+ } else {
+ if ((fdtmp = tpax_file_create_tmpfs_snapshot(
+ dctx,*uctx->path,
+ uctx->st)) < 0)
+ return TPAX_NESTED_ERROR(dctx);
+
+ if (lseek(fdtmp,0,SEEK_SET) < 0)
+ return TPAX_SYSTEM_ERROR(dctx);
+ }
}
/* append header */
@@ -147,6 +150,10 @@ int tpax_archive_append(
tpax_set_driver_cpos(dctx,dpos);
+ /* all done? */
+ if (!(S_ISREG(uctx->st->st_mode)))
+ return 0;
+
/* append data from snapshot */
if (fdtmp >= 0) {
if (!buf) {