aboutsummaryrefslogtreecommitdiffstats
path: root/lib/earlycpio.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/earlycpio.c')
-rw-r--r--lib/earlycpio.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/lib/earlycpio.c b/lib/earlycpio.c
index 7aa7ce250c94..3eb3e4722b8e 100644
--- a/lib/earlycpio.c
+++ b/lib/earlycpio.c
@@ -49,22 +49,23 @@ enum cpio_fields {
49 49
50/** 50/**
51 * cpio_data find_cpio_data - Search for files in an uncompressed cpio 51 * cpio_data find_cpio_data - Search for files in an uncompressed cpio
52 * @path: The directory to search for, including a slash at the end 52 * @path: The directory to search for, including a slash at the end
53 * @data: Pointer to the the cpio archive or a header inside 53 * @data: Pointer to the the cpio archive or a header inside
54 * @len: Remaining length of the cpio based on data pointer 54 * @len: Remaining length of the cpio based on data pointer
55 * @offset: When a matching file is found, this is the offset to the 55 * @nextoff: When a matching file is found, this is the offset from the
56 * beginning of the cpio. It can be used to iterate through 56 * beginning of the cpio to the beginning of the next file, not the
57 * the cpio to find all files inside of a directory path 57 * matching file itself. It can be used to iterate through the cpio
58 * to find all files inside of a directory path.
58 * 59 *
59 * @return: struct cpio_data containing the address, length and 60 * @return: struct cpio_data containing the address, length and
60 * filename (with the directory path cut off) of the found file. 61 * filename (with the directory path cut off) of the found file.
61 * If you search for a filename and not for files in a directory, 62 * If you search for a filename and not for files in a directory,
62 * pass the absolute path of the filename in the cpio and make sure 63 * pass the absolute path of the filename in the cpio and make sure
63 * the match returned an empty filename string. 64 * the match returned an empty filename string.
64 */ 65 */
65 66
66struct cpio_data find_cpio_data(const char *path, void *data, 67struct cpio_data find_cpio_data(const char *path, void *data,
67 size_t len, long *offset) 68 size_t len, long *nextoff)
68{ 69{
69 const size_t cpio_header_len = 8*C_NFIELDS - 2; 70 const size_t cpio_header_len = 8*C_NFIELDS - 2;
70 struct cpio_data cd = { NULL, 0, "" }; 71 struct cpio_data cd = { NULL, 0, "" };
@@ -124,7 +125,7 @@ struct cpio_data find_cpio_data(const char *path, void *data,
124 if ((ch[C_MODE] & 0170000) == 0100000 && 125 if ((ch[C_MODE] & 0170000) == 0100000 &&
125 ch[C_NAMESIZE] >= mypathsize && 126 ch[C_NAMESIZE] >= mypathsize &&
126 !memcmp(p, path, mypathsize)) { 127 !memcmp(p, path, mypathsize)) {
127 *offset = (long)nptr - (long)data; 128 *nextoff = (long)nptr - (long)data;
128 if (ch[C_NAMESIZE] - mypathsize >= MAX_CPIO_FILE_NAME) { 129 if (ch[C_NAMESIZE] - mypathsize >= MAX_CPIO_FILE_NAME) {
129 pr_warn( 130 pr_warn(
130 "File %s exceeding MAX_CPIO_FILE_NAME [%d]\n", 131 "File %s exceeding MAX_CPIO_FILE_NAME [%d]\n",