/* Initialise a list of files from the cpio that can be searched and indexed */ static void init_cpio_list(void) { assert(cpio_info(_cpio_archive, &cinfo) == 0); cpio_file_list = malloc(sizeof(cpio_entry_t) * cinfo.file_count); assert(cpio_file_list != NULL); for(int i = 0; i < cinfo.file_count; i++) { cpio_entry_t *ent = &(cpio_file_list[i]); ent->file = cpio_get_entry(_cpio_archive, i, &ent->name, &ent->size); assert(ent->file != NULL); } }
static void print_cpio_info(void) { struct cpio_info info; const char* name; unsigned long size; int i; cpio_info(_cpio_archive, &info); printf("CPIO: %d files found.\n", info.file_count); assert(info.file_count > 0); for (i = 0; i < info.file_count; i++) { void * addr; char buf[info.max_path_sz + 1]; buf[info.max_path_sz] = '\0'; addr = cpio_get_entry(_cpio_archive, i, &name, &size); assert(addr); strncpy(buf, name, info.max_path_sz); printf("%d) %-20s 0x%08x, %8ld bytes\n", i, buf, (uint32_t)addr, size); } printf("\n"); }