Home | History | Annotate | Download | only in libfec

Lines Matching refs:ecc

99 /* attempts to read and validate an ecc header from file position `offset' */
103 check(f->ecc.rsn > 0 && f->ecc.rsn < FEC_RSM);
114 /* there's obviously no ecc data at this point, so there is no need to
128 error("unsupported ecc version: %u", header.version);
132 error("unexpected ecc header size: %u", header.size);
136 error("invalid ecc roots: %u", header.roots);
139 if (f->ecc.roots != (int)header.roots) {
140 error("unexpected number of roots: %d vs %u", f->ecc.roots,
146 error("inconsistent ecc size %u", header.fec_size);
151 f->ecc.blocks = fec_div_round_up(f->data_size, FEC_BLOCKSIZE);
152 f->ecc.rounds = fec_div_round_up(f->ecc.blocks, f->ecc.rsn);
155 (uint32_t)f->ecc.rounds * f->ecc.roots * FEC_BLOCKSIZE) {
156 error("inconsistent ecc size %u", header.fec_size);
160 f->ecc.size = header.fec_size;
161 f->ecc.start = header.inp_size;
171 while (n < f->ecc.size) {
172 if (len > f->ecc.size - n) {
173 len = f->ecc.size - n;
176 if (!raw_pread(f, buf, len, f->ecc.start + n)) {
177 error("failed to read ecc: %s", strerror(errno));
188 f->ecc.valid = !memcmp(hash, header.hash, SHA256_DIGEST_LENGTH);
190 if (!f->ecc.valid) {
191 warn("ecc data not valid");
197 /* attempts to read an ecc header from `offset', and checks for a backup copy
212 warn("using backup ecc header");
345 /* locates, validates, and loads ecc data from `f->fd' */
355 f->ecc.start);
404 memset(&f->ecc, 0, sizeof(f->ecc));
467 /* populates `data' from the internal data in `f', returns a value <0 if ecc
474 if (!f->ecc.start) {
479 check(f->ecc.start >= f->data_size);
480 check(f->ecc.start < f->size);
481 check(f->ecc.start % FEC_BLOCKSIZE == 0)
483 data->valid = f->ecc.valid;
484 data->roots = f->ecc.roots;
485 data->blocks = f->ecc.blocks;
486 data->rounds = f->ecc.rounds;
487 data->start = f->ecc.start;
537 f->ecc.roots = roots;
538 f->ecc.rsn = FEC_RSM - roots;
558 f->data_size = f->size; /* until ecc and/or verity are loaded */