From af498808d3ac418dc84be14e42cae054afa5bac6 Mon Sep 17 00:00:00 2001 From: midipix Date: Sun, 31 May 2020 18:19:48 +0000 Subject: tpax_archive_append(): only create/write snapshots for regular files. --- src/logic/tpax_archive_append.c | 49 +++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'src') 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) { -- cgit v1.2.3