static int detail_sz_ts(struct backup *backup, const char *userid, FILE *out)
{
    struct backup_chunk *chunk = NULL;
    struct stat stat_buf;
    char timestamp[32] = "[unknown]";
    int r = 0;

    chunk = backup_get_latest_chunk(backup);
    if (chunk) {
        strftime(timestamp, sizeof(timestamp), "%F %T",
                 localtime(&chunk->ts_end));
        backup_chunk_free(&chunk);
    }

    r = fstat(backup->fd, &stat_buf);
    if (r) {
        fprintf(stderr, "fstat %s: %s\n", backup->data_fname, strerror(errno));
        stat_buf.st_size = -1;
    }

    fprintf(out, "%s\t" OFF_T_FMT "\t%s\t%s\n",
            userid,
            stat_buf.st_size,
            timestamp,
            backup->data_fname);

    return r;
}
Exemple #2
0
static int cmd_dump_chunk(struct backup *backup,
                          const struct cyrbu_cmd_options *options)
{
    struct backup_chunk *chunk = NULL;
    int chunk_id;
    int r;

    chunk_id = atoi(strarray_nth(options->argv, 0));
    if (chunk_id <= 0) return -1;

    chunk = backup_get_chunk(backup, chunk_id);
    if (!chunk) return IMAP_NOTFOUND;

    r = backup_read_chunk_data(backup, chunk, dump_buf, stdout);

    backup_chunk_free(&chunk);
    return r;
}