diff options
author | David Disseldorp | 2022-05-09 18:29:19 -0700 |
---|---|---|
committer | akpm | 2022-05-09 18:29:19 -0700 |
commit | da028e4c4b0279eb49f80220d8f7cc62b4a57ccb (patch) | |
tree | 06cf79a0ecbd9692d475802a9db3fe245c48a28a /init | |
parent | 7055197705709c59b8ab77e6a5c7d46d61edd96e (diff) |
initramfs: refactor do_header() cpio magic checks
Patch series "initramfs: "crc" cpio format and INITRAMFS_PRESERVE_MTIME", v7.
This patchset does some minor initramfs refactoring and allows cpio entry
mtime preservation to be disabled via a new Kconfig
INITRAMFS_PRESERVE_MTIME option.
Patches 4/6 to 6/6 implement support for creation and extraction of "crc"
cpio archives, which carry file data checksums. Basic tests for this
functionality can be found at https://github.com/rapido-linux/rapido/pull/163
This patch (of 6):
do_header() is called for each cpio entry and fails if the first six bytes
don't match "newc" magic. The magic check includes a special case error
message if POSIX.1 ASCII (cpio -H odc) magic is detected. This special
case POSIX.1 check can be nested under the "newc" mismatch code path to
avoid calling memcmp() twice in a non-error case.
Link: https://lkml.kernel.org/r/20220404093429.27570-1-ddiss@suse.de
Link: https://lkml.kernel.org/r/20220404093429.27570-2-ddiss@suse.de
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Martin Wilck <mwilck@suse.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Matthew Wilcox <willy@infradead.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'init')
-rw-r--r-- | init/initramfs.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/init/initramfs.c b/init/initramfs.c index 2f3d96dc3db6..2f79b3ec0b40 100644 --- a/init/initramfs.c +++ b/init/initramfs.c @@ -257,12 +257,11 @@ static int __init do_collect(void) static int __init do_header(void) { - if (memcmp(collected, "070707", 6)==0) { - error("incorrect cpio method used: use -H newc option"); - return 1; - } if (memcmp(collected, "070701", 6)) { - error("no cpio magic"); + if (memcmp(collected, "070707", 6) == 0) + error("incorrect cpio method used: use -H newc option"); + else + error("no cpio magic"); return 1; } parse_header(collected); |