/* 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; }
/* API function documented in wimlib.h */ WIMLIBAPI int wimlib_set_wim_info(WIMStruct *wim, const struct wimlib_wim_info *info, int which) { if (which & ~(WIMLIB_CHANGE_READONLY_FLAG | WIMLIB_CHANGE_GUID | WIMLIB_CHANGE_BOOT_INDEX | WIMLIB_CHANGE_RPFIX_FLAG)) return WIMLIB_ERR_INVALID_PARAM; if ((which & WIMLIB_CHANGE_BOOT_INDEX) && info->boot_index > wim->hdr.image_count) return WIMLIB_ERR_INVALID_IMAGE; if (which & WIMLIB_CHANGE_READONLY_FLAG) { if (info->is_marked_readonly) wim->hdr.flags |= WIM_HDR_FLAG_READONLY; else wim->hdr.flags &= ~WIM_HDR_FLAG_READONLY; } if (which & WIMLIB_CHANGE_GUID) copy_guid(wim->hdr.guid, info->guid); if (which & WIMLIB_CHANGE_BOOT_INDEX) wim->hdr.boot_idx = info->boot_index; if (which & WIMLIB_CHANGE_RPFIX_FLAG) { if (info->has_rpfix) wim->hdr.flags |= WIM_HDR_FLAG_RP_FIX; else wim->hdr.flags &= ~WIM_HDR_FLAG_RP_FIX; } return 0; }
UINTN read_gpt(VOID) { UINTN status; GPT_HEADER *header; GPT_ENTRY *entry; UINT64 entry_lba; UINTN entry_count, entry_size, i; Print(L"\nCurrent GUID partition table:\n"); // read GPT header status = read_sector(1, sector); if (status != 0) return status; // check signature header = (GPT_HEADER *)sector; if (header->signature != 0x5452415020494645ULL) { Print(L" No GPT partition table present!\n"); return 0; } if (header->spec_revision != 0x00010000UL) { Print(L" Warning: Unknown GPT spec revision 0x%08x\n", header->spec_revision); } if ((512 % header->entry_size) > 0 || header->entry_size > 512) { Print(L" Error: Invalid GPT entry size (misaligned or more than 512 bytes)\n"); return 0; } // read entries entry_lba = header->entry_lba; entry_size = header->entry_size; entry_count = header->entry_count; for (i = 0; i < entry_count; i++) { if (((i * entry_size) % 512) == 0) { status = read_sector(entry_lba, sector); if (status != 0) return status; entry_lba++; } entry = (GPT_ENTRY *)(sector + ((i * entry_size) % 512)); if (guids_are_equal(entry->type_guid, empty_guid)) continue; if (gpt_part_count == 0) { Print(L" # Start LBA End LBA Type\n"); } gpt_parts[gpt_part_count].index = i; gpt_parts[gpt_part_count].start_lba = entry->start_lba; gpt_parts[gpt_part_count].end_lba = entry->end_lba; gpt_parts[gpt_part_count].mbr_type = 0; copy_guid(gpt_parts[gpt_part_count].gpt_type, entry->type_guid); gpt_parts[gpt_part_count].gpt_parttype = gpt_parttype(gpt_parts[gpt_part_count].gpt_type); gpt_parts[gpt_part_count].active = FALSE; Print(L" %d %12lld %12lld %s\n", gpt_parts[gpt_part_count].index + 1, gpt_parts[gpt_part_count].start_lba, gpt_parts[gpt_part_count].end_lba, gpt_parts[gpt_part_count].gpt_parttype->name); gpt_part_count++; } if (gpt_part_count == 0) { Print(L" No partitions defined\n"); return 0; } return 0; }