Skip to content

Commit

Permalink
FIXME track and print newbytes
Browse files Browse the repository at this point in the history
  • Loading branch information
gperciva committed Apr 11, 2018
1 parent b18ab3a commit ebf1253
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 0 deletions.
1 change: 1 addition & 0 deletions tar/bsdtar.h
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ void siginfo_init(struct bsdtar *);
void siginfo_setinfo(struct bsdtar *, const char * oper,
const char * path, int64_t size, int file_count,
int64_t total_uncompressed);
void siginfo_setchunks(void *);
void siginfo_printinfo(struct bsdtar *, off_t progress);
void siginfo_done(struct bsdtar *);
void tarsnap_mode_print_stats(struct bsdtar *bsdtar);
Expand Down
5 changes: 5 additions & 0 deletions tar/chunks/chunks.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ void chunks_write_extrastats_copy(CHUNKS_W *, size_t);
*/
int chunks_write_printstats(FILE *, CHUNKS_W *, int);

/**
* FIXME
*/
uint64_t chunks_write_newzbytes(CHUNKS_W * C);

/**
* chunks_write_checkpoint(C):
* Create a checkpoint for the write transaction associated with the cookie
Expand Down
12 changes: 12 additions & 0 deletions tar/chunks/chunks_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ chunks_write_printstats(FILE * stream, CHUNKS_W * C, int csv)
return (-1);
}

/**
* FIXME
*/
uint64_t
chunks_write_newzbytes(CHUNKS_W * C)
{

return (C->stats_new.s_zlen + C->stats_extra.s_zlen
+ STORAGE_FILE_OVERHEAD *
(C->stats_new.nchunks + C->stats_extra.nchunks));
}

/**
* chunks_write_checkpoint(C):
* Create a checkpoint for the write transaction associated with the cookie
Expand Down
4 changes: 4 additions & 0 deletions tar/multitape/multitape_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <unistd.h>

#include "asprintf.h"
#include "bsdtar.h"
#include "chunkify.h"
#include "chunks.h"
#include "crypto.h"
Expand Down Expand Up @@ -482,6 +483,9 @@ writetape_open(uint64_t machinenum, const char * cachedir,
if ((d->C = chunks_write_start(cachedir, d->S, MAXCHUNK)) == NULL)
goto err5;

/* Pass write cookie to siginfo. */
siginfo_setchunks(d->C);

/*
* Make sure that there isn't an archive already present with either
* the specified name or that plus ".part" (in case the user decides
Expand Down
31 changes: 31 additions & 0 deletions tar/siginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,15 @@ __FBSDID("$FreeBSD: src/usr.bin/tar/siginfo.c,v 1.2 2008/05/22 21:08:36 cperciva
#include <string.h>

#include "bsdtar.h"
#include "chunks.h"
#include "humansize.h"
#include "tarsnap_opt.h"

/* Is there a pending SIGINFO or SIGUSR1? */
static volatile sig_atomic_t siginfo_received = 0;

static CHUNKS_W * chunks_write_cookie = NULL;

struct siginfo_data {
/* What sort of operation are we doing? */
char * oper;
Expand Down Expand Up @@ -105,6 +108,13 @@ siginfo_init(struct bsdtar *bsdtar)
#endif
}

void
siginfo_setchunks(void * cookie)
{

chunks_write_cookie = cookie;
}

void
siginfo_setinfo(struct bsdtar *bsdtar, const char * oper, const char * path,
int64_t size, int file_count, int64_t total_uncompressed)
Expand Down Expand Up @@ -132,6 +142,7 @@ siginfo_printinfo(struct bsdtar *bsdtar, off_t progress)
char * s_progress;
char * s_size;
char * s_total_uncompressed;
char * s_total_new;

/* Sanity check. */
assert(progress >= 0);
Expand Down Expand Up @@ -190,6 +201,26 @@ siginfo_printinfo(struct bsdtar *bsdtar, off_t progress)
bsdtar->siginfo->total_uncompressed);
}
}
/* Print new data (if applicable). */
if (chunks_write_cookie != NULL) {
if (tarsnap_opt_humanize_numbers) {
if ((s_total_new = humansize(
chunks_write_newzbytes(chunks_write_cookie)
)) == NULL)
goto err0;
safe_fprintf(stderr, "; New data: %s ",
s_total_new);

/* Clean up. */
free(s_total_new);
} else {
safe_fprintf(stderr, "; New data %" PRId64
" bytes",
chunks_write_newzbytes(chunks_write_cookie)
);
}
}

if (!bsdtar->verbose)
fprintf(stderr, "\n");
siginfo_received = 0;
Expand Down

0 comments on commit ebf1253

Please sign in to comment.