summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/logic/tpax_archive_append.c211
1 files changed, 0 insertions, 211 deletions
diff --git a/src/logic/tpax_archive_append.c b/src/logic/tpax_archive_append.c
index f467c4a..219c596 100644
--- a/src/logic/tpax_archive_append.c
+++ b/src/logic/tpax_archive_append.c
@@ -256,216 +256,6 @@ static int tpax_archive_append_queue_item(
return 0;
}
-static int tpax_archive_append_one(
- const struct tpax_driver_ctx * dctx,
- const struct tpax_unit_ctx * uctx,
- const struct dirent * dent,
- int fdat,
- const char * prefix,
- const struct tpax_dirent * parent,
- const char * pdir)
-{
- struct tpax_unit_ctx * unit;
- struct tpax_ustar_header uhdr;
- off_t hpos;
- off_t dpos;
- int fdout;
- int fdtmp;
- ssize_t nread;
- ssize_t nbytes;
- void * buf;
- size_t buflen;
- size_t cmplen;
- void * membuf;
- size_t nlen;
- const char * path;
- const char * src;
- char * dst;
- char pbuf[1024];
-
- /* fake uctx for recursion items */
- unit = 0;
-
- if (dent && tpax_get_unit_ctx(
- dctx,fdat,dent->d_name,
- &unit) < 0)
- return TPAX_NESTED_ERROR(dctx);
-
- uctx = dent ? unit : uctx;
-
- /* prefixed path */
- if (!prefix && !parent && !pdir) {
- path = *uctx->path;
-
- } else {
- nlen = strlen(*uctx->path);
- nlen += prefix ? strlen(prefix) + 1 : 0;
- nlen += parent ? strlen(parent->dirent.d_name) + 1 : 0;
-
- if (nlen >= sizeof(pbuf))
- return TPAX_BUFFER_ERROR(dctx);
-
- dst = pbuf;
-
- if (prefix) {
- src = prefix;
-
- for (; *src; )
- *dst++ = *src++;
-
- if (dst[-1] != '/')
- *dst++ = '/';
- }
-
- if (parent) {
- src = parent->dirent.d_name;
-
- for (; *src; )
- *dst++ = *src++;
-
- *dst++ = '/';
- }
-
- if (pdir) {
- src = pdir;
-
- for (; *src; )
- *dst++ = *src++;
-
- *dst++ = '/';
- }
-
- src = *uctx->path;
-
- for (; *src; )
- *dst++ = *src++;
-
- *dst = 0;
- path = pbuf;
- }
-
- /* record errors */
- tpax_driver_set_ectx(
- dctx,0,path);
-
- /* driver */
- fdout = tpax_driver_fdout(dctx);
-
- /* header and data offsets: todo pax and cpio */
- hpos = tpax_get_driver_cpos(dctx);
- dpos = hpos + sizeof(uhdr);
-
- /* header */
- if (tpax_init_ustar_header(
- dctx,path,uctx->st,
- *uctx->link,&uhdr) < 0)
- return tpax_archive_append_ret(
- TPAX_NESTED_ERROR(dctx),
- unit);
-
- /* buffer */
- membuf = 0;
- fdtmp = -1;
-
- /* associated data? */
- if S_ISREG(uctx->st->st_mode) {
- buf = tpax_get_driver_anon_map_addr(
- dctx,&buflen);
-
- if (buflen >= (cmplen = uctx->st->st_size))
- membuf = buf;
-
- /* snapshot */
- if (membuf) {
- if (tpax_file_create_memory_snapshot(
- dctx,fdat,*uctx->path,
- uctx->st,membuf) < 0)
- return tpax_archive_append_ret(
- TPAX_NESTED_ERROR(dctx),
- unit);
- } else {
- if ((fdtmp = tpax_file_create_tmpfs_snapshot(
- dctx,fdat,*uctx->path,
- uctx->st)) < 0)
- return tpax_archive_append_ret(
- TPAX_NESTED_ERROR(dctx),
- unit);
-
- if (lseek(fdtmp,0,SEEK_SET) < 0)
- return tpax_archive_append_ret(
- TPAX_SYSTEM_ERROR(dctx),
- unit);
- }
- }
-
- /* append header */
- if (tpax_archive_append_memory_data(fdout,&uhdr,ssizeof(uhdr)) < 0) {
- if (fdtmp >= 0)
- close(fdtmp);
-
- return tpax_archive_append_ret(
- TPAX_SYSTEM_ERROR(dctx),
- unit);
- }
-
- tpax_set_driver_cpos(dctx,dpos);
-
- /* all done? */
- if (!(S_ISREG(uctx->st->st_mode))) {
- tpax_archive_append_ret(0,unit);
- return 0;
- }
-
- /* append data from snapshot */
- if (fdtmp >= 0) {
- buf = tpax_get_driver_anon_map_addr(
- dctx,&buflen);
-
- for (nread=0; nread<uctx->st->st_size; ) {
- nbytes = read(fdtmp,buf,buflen);
-
- while ((nbytes < 0) && (errno == EINTR))
- nbytes = read(fdtmp,buf,buflen);
-
- if (nbytes < 0) {
- close(fdtmp);
- return tpax_archive_append_ret(
- TPAX_SYSTEM_ERROR(dctx),
- unit);
-
- } else if (nbytes == 0) {
- close(fdtmp);
- return tpax_archive_append_ret(
- TPAX_CUSTOM_ERROR(dctx,TPAX_ERR_FLOW_ERROR),
- unit);
-
- } else {
- nread += nbytes;
- }
-
- if (tpax_archive_append_memory_data(fdout,buf,nbytes) < 0) {
- close(fdtmp);
- return tpax_archive_append_ret(
- TPAX_SYSTEM_ERROR(dctx),
- unit);
- }
- }
-
- close(fdtmp);
- } else {
- if (tpax_archive_append_memory_data(
- fdout,membuf,
- uctx->st->st_size) < 0)
- return tpax_archive_append_ret(
- TPAX_SYSTEM_ERROR(dctx),
- unit);
- }
-
- return tpax_archive_append_ret(
- tpax_archive_append_pad(dctx,fdout,uctx->st),
- unit);
-}
-
static int tpax_archive_append_dir_entries(
const struct tpax_driver_ctx * dctx,
struct tpax_dirent * dent)
@@ -585,7 +375,6 @@ int tpax_archive_append_item(
(void)uctx;
(void)tpax_archive_append_dir_entries;
- (void)tpax_archive_append_one;
(void)tpax_append_prefix_item;
return 0;