diff options
author | Tang Chen <tangchen@cn.fujitsu.com> | 2013-08-14 05:37:07 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-14 17:24:01 -0400 |
commit | 598bae70c2a8e35c8d39b610cca2b32afcf047af (patch) | |
tree | e0e49b046357dc1e6aecd69e4ee0fd9a7f9e456c /lib/earlycpio.c | |
parent | d7b2c3d8fb6f53a370696572ef3578a7f8723147 (diff) |
earlycpio.c: Fix the confusing comment of find_cpio_data().
The comments of find_cpio_data() says:
* @offset: When a matching file is found, this is the offset to the
* beginning of the cpio. ......
But according to the code,
dptr = PTR_ALIGN(p + ch[C_NAMESIZE], 4);
nptr = PTR_ALIGN(dptr + ch[C_FILESIZE], 4);
....
*offset = (long)nptr - (long)data; /* data is the cpio file */
@offset is the offset of the next file, not the matching file itself.
This is confused and may cause unnecessary waste of time to debug.
So fix it.
As Tejun Heo suggested, rename @offset to @nextoff which is more clear
to users. And also adjust the new comments.
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Reviewed-by: Zhang Yanfei <zhangyanfei@cn.fujitsu.com>
Reviewed-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'lib/earlycpio.c')
-rw-r--r-- | lib/earlycpio.c | 27 |
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 | ||
66 | struct cpio_data find_cpio_data(const char *path, void *data, | 67 | struct 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", |