summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/kexec-uImage.h1
-rw-r--r--kexec/arch/arm/kexec-uImage-arm.c2
-rw-r--r--kexec/arch/ppc/kexec-uImage-ppc.c2
-rw-r--r--kexec/arch/sh/kexec-uImage-sh.c2
-rw-r--r--kexec/kexec-uImage.c14
5 files changed, 17 insertions, 4 deletions
diff --git a/include/kexec-uImage.h b/include/kexec-uImage.h
index 8c7707df..266ca739 100644
--- a/include/kexec-uImage.h
+++ b/include/kexec-uImage.h
@@ -9,5 +9,6 @@ struct Image_info {
};
int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch);
+int uImage_probe_kernel(const unsigned char *buf, off_t len, unsigned int arch);
int uImage_load(const unsigned char *buf, off_t len, struct Image_info *info);
#endif
diff --git a/kexec/arch/arm/kexec-uImage-arm.c b/kexec/arch/arm/kexec-uImage-arm.c
index 48751855..03c2f4dd 100644
--- a/kexec/arch/arm/kexec-uImage-arm.c
+++ b/kexec/arch/arm/kexec-uImage-arm.c
@@ -11,7 +11,7 @@
int uImage_arm_probe(const char *buf, off_t len)
{
- return uImage_probe(buf, len, IH_ARCH_ARM);
+ return uImage_probe_kernel(buf, len, IH_ARCH_ARM);
}
int uImage_arm_load(int argc, char **argv, const char *buf, off_t len,
diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c
index eb477f1f..ccaf6d7f 100644
--- a/kexec/arch/ppc/kexec-uImage-ppc.c
+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
@@ -48,7 +48,7 @@ void uImage_ppc_usage(void)
int uImage_ppc_probe(const char *buf, off_t len)
{
- return uImage_probe(buf, len, IH_ARCH_PPC);
+ return uImage_probe_kernel(buf, len, IH_ARCH_PPC);
}
static int ppc_load_bare_bits(int argc, char **argv, const char *buf,
diff --git a/kexec/arch/sh/kexec-uImage-sh.c b/kexec/arch/sh/kexec-uImage-sh.c
index e9831653..130f12ca 100644
--- a/kexec/arch/sh/kexec-uImage-sh.c
+++ b/kexec/arch/sh/kexec-uImage-sh.c
@@ -13,7 +13,7 @@
int uImage_sh_probe(const char *buf, off_t len)
{
- return uImage_probe(buf, len, IH_ARCH_SH);
+ return uImage_probe_kernel(buf, len, IH_ARCH_SH);
}
int uImage_sh_load(int argc, char **argv, const char *buf, off_t len,
diff --git a/kexec/kexec-uImage.c b/kexec/kexec-uImage.c
index 3bc85c55..3799a3bb 100644
--- a/kexec/kexec-uImage.c
+++ b/kexec/kexec-uImage.c
@@ -16,6 +16,10 @@
* Basic uImage loader. Not rocket science.
*/
+/*
+ * Returns the image type if everything goes well. This would
+ * allow the user to decide if the image is of their interest.
+ */
int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
{
struct image_header header;
@@ -84,7 +88,15 @@ int uImage_probe(const unsigned char *buf, off_t len, unsigned int arch)
return -1;
}
#endif
- return 0;
+ return (int)header.ih_type;
+}
+
+int uImage_probe_kernel(const unsigned char *buf, off_t len, unsigned int arch)
+{
+ int type = uImage_probe(buf, len, arch);
+
+ return (type == IH_TYPE_KERNEL || type == IH_TYPE_KERNEL_NOLOAD) ?
+ 0 : -1;
}
#ifdef HAVE_LIBZ