static void setup_chfd_reads_from_slist_blks_got(struct asfd *chfd, int *cr, struct slist *slist, int number_of_blks, uint64_t interrupt) { uint64_t file_no=1; int blk_index=1; struct blk blk; struct iobuf iobuf; struct sbuf *s; if(!slist) return; for(s=slist->head; s; s=s->next) { if(sbuf_is_filedata(s) && !sbuf_is_encrypted(s)) // Not working for proto2 yet. { int b; if(interrupt==file_no++) continue; for(b=0; b<number_of_blks; b++) { blk.index=blk_index++; blk.savepath=0; blk_to_iobuf_index_and_savepath(&blk, &iobuf); asfd_mock_read_iobuf(chfd, cr, 0, &iobuf); } } } }
static int results_to_fd(struct asfd *asfd) { static struct iobuf wbuf; struct blk *b; struct blk *l; if(!asfd->blist->last_index) return 0; // Need to start writing the results down the fd. for(b=asfd->blist->head; b && b!=asfd->blist->blk_to_dedup; b=l) { if(b->got==BLK_GOT) { // Need to write to fd. blk_to_iobuf_index_and_savepath(b, &wbuf); switch(asfd->append_all_to_write_buffer(asfd, &wbuf)) { case APPEND_OK: break; case APPEND_BLOCKED: asfd->blist->head=b; return 0; // Try again later. default: return -1; } } else { // If the last in the sequence is BLK_NOT_GOT, // Send a 'wrap_up' message. if(!b->next || b->next==asfd->blist->blk_to_dedup) { blk_to_iobuf_wrap_up(b, &wbuf); switch(asfd->append_all_to_write_buffer(asfd, &wbuf)) { case APPEND_OK: break; case APPEND_BLOCKED: asfd->blist->head=b; return 0; // Try again later. default: return -1; } } } l=b->next; blk_free(&b); } asfd->blist->head=b; if(!b) asfd->blist->tail=NULL; return 0; }