int get_footer(server *srv, chunkqueue *cq, vhd_state_t *state, off_t *curr_off) { int err; vhd_context_t *vhd = &state->vhd; err = fill(srv, cq, &vhd->footer, sizeof(vhd_footer_t), 0, curr_off); if (err) return err; if (*curr_off < 0 + sizeof(vhd_footer_t)) return 0; DEBUGLOG("s", "Footer all in"); vhd_footer_in(&vhd->footer); err = vhd_validate_footer(&vhd->footer); if (err) LOG("sd", "ERROR: VHD footer invalid:", err); if (!vhd_type_dynamic(vhd)) { LOG("s", "ERROR: static VHDs are not supported"); err = -EINVAL; } return err; }
static int __vhd_journal_read_footer(vhd_journal_t *j, vhd_footer_t *footer, uint32_t type) { int err; vhd_journal_entry_t entry; err = vhd_journal_read_entry(j, &entry); if (err) return err; if (entry.type != type) return -EINVAL; if (entry.size != sizeof(vhd_footer_t)) return -EINVAL; err = vhd_journal_read(j, footer, entry.size); if (err) return err; vhd_footer_in(footer); return vhd_validate_footer(footer); }