Lines Matching refs:offset

40 /* performs a binary search to find a metadata offset from a file so that
43 static int find_offset(uint64_t file_size, int roots, uint64_t *offset,
46 check(offset);
70 *offset = mi;
71 debug("file_size = %" PRIu64 " -> offset = %" PRIu64, file_size,
77 warn("could not determine offset");
88 /* computes the verity metadata offset for a file with size `f->size' */
89 static int find_verity_offset(fec_handle *f, uint64_t *offset)
92 check(offset);
94 return find_offset(f->data_size, 0, offset, get_verity_size,
98 /* attempts to read and validate an ecc header from file position `offset' */
99 static int parse_ecc_header(fec_handle *f, uint64_t offset)
105 debug("offset = %" PRIu64, offset);
107 if (offset > f->size - sizeof(fec_header)) {
115 if (!raw_pread(f, &header, sizeof(fec_header), offset)) {
120 /* move offset back to the beginning of the block for validating header */
121 offset -= offset % FEC_BLOCKSIZE;
149 if (offset < header.fec_size ||
150 offset - header.fec_size != header.inp_size) {
151 error("unexpected input size: %" PRIu64 " vs %" PRIu64, offset,
203 /* attempts to read an ecc header from `offset', and checks for a backup copy
205 static int parse_ecc(fec_handle *f, uint64_t offset)
208 check(offset % FEC_BLOCKSIZE == 0);
209 check(offset < UINT64_MAX - FEC_BLOCKSIZE);
212 if (parse_ecc_header(f, offset) == 0) {
217 if (parse_ecc_header(f, offset + FEC_BLOCKSIZE - sizeof(fec_header)) == 0) {
226 `offset' */
227 static int get_squashfs_size(fec_handle *f, uint64_t *offset)
230 check(offset);
249 *offset = sq.bytes_used_4K_padded;
254 `offset' */
255 static int get_ext4_size(fec_handle *f, uint64_t *offset)
259 check(offset);
276 *offset = info.len;
281 `f->flags', tries all supported types, and returns the size in `offset' */
282 static int get_fs_size(fec_handle *f, uint64_t *offset)
285 check(offset);
288 return get_ext4_size(f, offset);
290 return get_squashfs_size(f, offset);
293 int rc = get_ext4_size(f, offset);
300 rc = get_squashfs_size(f, offset);
316 uint64_t offset = f->data_size - VERITY_METADATA_SIZE;
319 if (verity_parse_header(f, offset) == 0) {
320 debug("found at %" PRIu64 " (start %" PRIu64 ")", offset,
328 if (find_verity_offset(f, &offset) == 0 &&
329 verity_parse_header(f, offset) == 0) {
330 debug("found at %" PRIu64 " (start %" PRIu64 ")", offset,
336 int rc = get_fs_size(f, &offset);
339 debug("file system size = %" PRIu64, offset);
340 rc = verity_parse_header(f, offset);
343 debug("found at %" PRIu64 " (start %" PRIu64 ")", offset,
357 uint64_t offset = f->data_size - FEC_BLOCKSIZE;
359 if (parse_ecc(f, offset) == 0) {
360 debug("found at %" PRIu64 " (start %" PRIu64 ")", offset,