static int create_raw(io_t io) { int rc = 0; size_t ebs_written = 0; /* eraseblocks written already... */ size_t vol_tab_size; list_t ptr; list_t pfi_raws = mk_empty(); /* list of raw sections from a pfi */ list_t pfi_ubis = mk_empty(); /* list of ubi sections from a pfi */ list_t raw_pebs = mk_empty(); /* list of raw eraseblocks */ struct ubi_vtbl_record *vol_tab = NULL; pdd_data_t pdd = NULL; rc = init_vol_tab (&vol_tab, &vol_tab_size); if (rc != 0) { err_msg("Cannot initialize volume table."); goto err; } rc = read_pdd_data(io->fp_pdd, &pdd, err_buf, ERR_BUF_SIZE); if (rc != 0) { err_msg("Cannot read necessary pdd_data: %s rc: %d", err_buf, rc); goto err; } rc = read_pfi_headers(&pfi_raws, &pfi_ubis, io->fp_pfi, err_buf, ERR_BUF_SIZE); if (rc != 0) { err_msg("Cannot read pfi header: %s rc: %d", err_buf, rc); goto err; } pfi_raw_t pfi_raw; foreach(pfi_raw, ptr, pfi_raws) { rc = memorize_raw_eb(pfi_raw, pdd, &raw_pebs, io); if (rc != 0) { err_msg("Cannot create raw_block in mem. rc: %d\n", rc); goto err; } }
relation_base * sieve_relation_plugin::mk_empty(const relation_signature & s) { UNREACHABLE(); return 0; #if 0 svector<bool> inner_cols(s.size()); extract_inner_columns(s, inner_cols.c_ptr()); return mk_empty(s, inner_cols.c_ptr()); #endif }
relation_base * udoc_plugin::mk_full(func_decl* p, const relation_signature & s) { udoc_relation* r = get(mk_empty(s)); r->get_udoc().push_back(dm(s).allocateX()); return r; }
relation_base * sieve_relation_plugin::mk_empty(const relation_base & original) { return mk_empty(static_cast<const sieve_relation &>(original)); }
sieve_relation * sieve_relation_plugin::mk_empty(const sieve_relation & original) { return static_cast<sieve_relation *>(mk_empty(original.get_signature(), original.get_kind())); }
/** * pfiflash_with_options - exposed func to flash memory with a PFI file * @pfi PFI data file pointer * @complete flag to erase unmapped volumes * @seqnum sequence number * @compare flag to compare * @pdd_handling method to handle pdd (keep, merge, overwrite...) * * Error handling: * when bootenv can't be created * - returns -PFIFLASH_ERR_BOOTENV_CREATE, err_buf matches text to err * when PFI headers can't be read, or * when fail to skip raw sections, or * when error occurs while processing raw volumes, or * when fail to erase unmapped UBI vols, or * when error occurs while processing UBI volumes, or * when error occurs while mirroring UBI volumes * - passes rc, prepends err_buf with contextual aid **/ int pfiflash_with_options(FILE* pfi, int complete, int seqnum, int compare, pdd_handling_t pdd_handling, const char* rawdev, char *err_buf, size_t err_buf_size) { int rc; bootenv_t bootenv; pdd_func_t pdd_f; if (pfi == NULL) return -EINVAL; rc = 0; pdd_f = NULL; /* If the user didnt specify a seqnum we start per default * with the index 0 */ int curr_seqnum = seqnum < 0 ? 0 : seqnum; list_t pfi_raws = mk_empty(); /* list of raw sections from a pfi */ list_t pfi_ubis = mk_empty(); /* list of ubi sections from a pfi */ rc = bootenv_create(&bootenv); if (rc != 0) { rc = -PFIFLASH_ERR_BOOTENV_CREATE; EBUF(PFIFLASH_ERRSTR[-rc], ""); goto err; } rc = read_pfi_headers(&pfi_raws, &pfi_ubis, pfi, err_buf, err_buf_size); if (rc != 0) { EBUF_PREPEND("reading PFI header"); goto err; } if (rawdev == NULL || compare) rc = skip_raw_volumes(pfi, pfi_raws, err_buf, err_buf_size); else rc = process_raw_volumes(pfi, pfi_raws, rawdev, err_buf, err_buf_size); if (rc != 0) { EBUF_PREPEND("handling raw section"); goto err; } if (complete && !compare) { rc = erase_unmapped_ubi_volumes(EXAMPLE_UBI_DEVICE, pfi_ubis, err_buf, err_buf_size); if (rc != 0) { EBUF_PREPEND("deleting unmapped UBI volumes"); goto err; } } if (((int)pdd_handling >= 0) && (pdd_handling < PDD_HANDLING_NUM)) pdd_f = pdd_funcs[pdd_handling]; else { rc = -PFIFLASH_ERR_PDD_UNKNOWN; EBUF(PFIFLASH_ERRSTR[-rc]); goto err; } if (!compare) { rc = process_ubi_volumes(pfi, curr_seqnum, pfi_ubis, bootenv, pdd_f, UBI_REMOVE, err_buf, err_buf_size); if (rc != 0) { EBUF_PREPEND("removing UBI volumes"); goto err; } rc = process_ubi_volumes(pfi, curr_seqnum, pfi_ubis, bootenv, pdd_f, UBI_WRITE, err_buf, err_buf_size); if (rc != 0) { EBUF_PREPEND("writing UBI volumes"); goto err; } if (seqnum < 0) { /* mirror redundant pairs */ rc = mirror_ubi_volumes(EXAMPLE_UBI_DEVICE, pfi_ubis, err_buf, err_buf_size); if (rc != 0) { EBUF_PREPEND("mirroring UBI volumes"); goto err; } } } else { /* only compare volumes, don't alter the content */ rc = process_ubi_volumes(pfi, curr_seqnum, pfi_ubis, bootenv, pdd_f, UBI_COMPARE, err_buf, err_buf_size); if (rc == -PFIFLASH_CMP_DIFF) /* update is necessary, return positive value */ rc = 1; if (rc < 0) { EBUF_PREPEND("comparing UBI volumes"); goto err; } } err: pfi_raws = remove_all((free_func_t)&free_pfi_raw, pfi_raws); pfi_ubis = remove_all((free_func_t)&free_pfi_ubi, pfi_ubis); bootenv_destroy(&bootenv); return rc; }