/* API function documented in wimlib.h */ WIMLIBAPI int wimlib_get_wim_info(WIMStruct *wim, struct wimlib_wim_info *info) { memset(info, 0, sizeof(struct wimlib_wim_info)); copy_guid(info->guid, wim->hdr.guid); info->image_count = wim->hdr.image_count; info->boot_index = wim->hdr.boot_idx; info->wim_version = wim->hdr.wim_version; info->chunk_size = wim->chunk_size; info->part_number = wim->hdr.part_number; info->total_parts = wim->hdr.total_parts; info->compression_type = wim->compression_type; info->total_bytes = wim_info_get_total_bytes(wim->wim_info); info->has_integrity_table = wim_has_integrity_table(wim); info->opened_from_file = (wim->filename != NULL); info->is_readonly = (wim->hdr.flags & WIM_HDR_FLAG_READONLY) || (wim->hdr.total_parts != 1) || (wim->filename && taccess(wim->filename, W_OK)); info->has_rpfix = (wim->hdr.flags & WIM_HDR_FLAG_RP_FIX) != 0; info->is_marked_readonly = (wim->hdr.flags & WIM_HDR_FLAG_READONLY) != 0; info->write_in_progress = (wim->hdr.flags & WIM_HDR_FLAG_WRITE_IN_PROGRESS) != 0; info->metadata_only = (wim->hdr.flags & WIM_HDR_FLAG_METADATA_ONLY) != 0; info->resource_only = (wim->hdr.flags & WIM_HDR_FLAG_RESOURCE_ONLY) != 0; info->spanned = (wim->hdr.flags & WIM_HDR_FLAG_SPANNED) != 0; info->pipable = wim_is_pipable(wim); return 0; }
/* * check_wim_integrity(): * * Verifies the integrity of the WIM by making sure the SHA1 message digests of * ~10 MiB chunks of the WIM match up with the values given in the integrity * table. * * @wim: * The WIM, opened for reading. * * Returns: * > 0 (WIMLIB_ERR_INVALID_INTEGRITY_TABLE, WIMLIB_ERR_READ, * WIMLIB_ERR_UNEXPECTED_END_OF_FILE) on error * 0 (WIM_INTEGRITY_OK) if the integrity was checked successfully and there * were no inconsistencies. * -1 (WIM_INTEGRITY_NOT_OK) if the WIM failed the integrity check. * -2 (WIM_INTEGRITY_NONEXISTENT) if the WIM contains no integrity * information. */ int check_wim_integrity(WIMStruct *wim) { int ret; u64 bytes_to_check; struct integrity_table *table; u64 end_lookup_table_offset; if (!wim_has_integrity_table(wim)) { DEBUG("No integrity information."); return WIM_INTEGRITY_NONEXISTENT; } end_lookup_table_offset = wim->hdr.lookup_table_reshdr.offset_in_wim + wim->hdr.lookup_table_reshdr.size_in_wim; if (end_lookup_table_offset < WIM_HEADER_DISK_SIZE) { ERROR("WIM lookup table ends before WIM header ends!"); return WIMLIB_ERR_INVALID_INTEGRITY_TABLE; } bytes_to_check = end_lookup_table_offset - WIM_HEADER_DISK_SIZE; ret = read_integrity_table(wim, bytes_to_check, &table); if (ret) return ret; ret = verify_integrity(&wim->in_fd, wim->filename, table, bytes_to_check, wim->progfunc, wim->progctx); FREE(table); return ret; }