// SPDX-License-Identifier: GPL-2.0-only /* ----------------------------------------------------------------------- * * * Copyright 2012 Intel Corporation; author H. Peter Anvin * * ----------------------------------------------------------------------- */ /* * earlycpio.c * * Find a specific cpio member; must precede any compressed content. * This is used to locate data items in the initramfs used by the * kernel itself during early boot (before the main initramfs is * decompressed.) It is the responsibility of the initramfs creator * to ensure that these items are uncompressed at the head of the * blob. Depending on the boot loader or package tool that may be a * separate file or part of the same file. */ #include <linux/earlycpio.h> #include <linux/kernel.h> #include <linux/string.h> enum cpio_fields { … }; /** * find_cpio_data - Search for files in an uncompressed cpio * @path: The directory to search for, including a slash at the end * @data: Pointer to the cpio archive or a header inside * @len: Remaining length of the cpio based on data pointer * @nextoff: When a matching file is found, this is the offset from the * beginning of the cpio to the beginning of the next file, not the * matching file itself. It can be used to iterate through the cpio * to find all files inside of a directory path. * * Return: &struct cpio_data containing the address, length and * filename (with the directory path cut off) of the found file. * If you search for a filename and not for files in a directory, * pass the absolute path of the filename in the cpio and make sure * the match returned an empty filename string. */ struct cpio_data find_cpio_data(const char *path, void *data, size_t len, long *nextoff) { … }