mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <linux@rempel-privat.de>
To: barebox@lists.infradead.org
Subject: [RFC PATCH 2/7] filetype: add ELF type
Date: Sun, 29 Apr 2018 15:09:02 +0200	[thread overview]
Message-ID: <20180429130907.20506-3-linux@rempel-privat.de> (raw)
In-Reply-To: <20180429130907.20506-1-linux@rempel-privat.de>

From: Antony Pavlov <antonynpavlov@gmail.com>

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 common/filetype.c  | 5 +++++
 include/filetype.h | 1 +
 2 files changed, 6 insertions(+)

diff --git a/common/filetype.c b/common/filetype.c
index 444ec14cc..77cf9a105 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -27,6 +27,7 @@
 #include <envfs.h>
 #include <disks.h>
 #include <image-sparse.h>
+#include <elf.h>
 
 struct filetype_str {
 	const char *name;	/* human readable filetype */
@@ -68,6 +69,7 @@ static const struct filetype_str filetype_str[] = {
 	[filetype_kwbimage_v1] = { "MVEBU kwbimage (v1)", "kwb" },
 	[filetype_android_sparse] = { "Android sparse image", "sparse" },
 	[filetype_arm64_linux_image] = { "ARM aarch64 Linux image", "aarch64-linux" },
+	[filetype_elf] = { "ELF", "elf" },
 };
 
 const char *file_type_to_string(enum filetype f)
@@ -344,6 +346,9 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
 		buf[7] == 0x47530000)
 		return filetype_ch_image_be;
 
+	if (strncmp(buf8, ELFMAG, 4) == 0)
+		return filetype_elf;
+
 	return filetype_unknown;
 }
 
diff --git a/include/filetype.h b/include/filetype.h
index 9986938dd..3b930bf94 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -41,6 +41,7 @@ enum filetype {
 	filetype_kwbimage_v1,
 	filetype_android_sparse,
 	filetype_arm64_linux_image,
+	filetype_elf,
 	filetype_max,
 };
 
-- 
2.14.1


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2018-04-29 13:09 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-29 13:09 [RFC PATCH 0/7] provide ELF/KEXEC support for MIPS ath79 and malta Oleksij Rempel
2018-04-29 13:09 ` [RFC PATCH 1/7] resource: add create_resource() helper function Oleksij Rempel
2018-04-29 13:09 ` Oleksij Rempel [this message]
2018-04-29 13:09 ` [RFC PATCH 3/7] bootm: add kexec ELF support Oleksij Rempel
2018-05-04  5:54   ` Sascha Hauer
2018-05-04 10:08     ` Antony Pavlov
2018-05-04  9:53       ` Oleksij Rempel
2018-05-04 13:09         ` Antony Pavlov
2018-04-29 13:09 ` [RFC PATCH 4/7] MIPS: add kexec ELF loading support Oleksij Rempel
2018-04-29 13:09 ` [RFC PATCH 5/7] MIPS: ath79: add kexec support Oleksij Rempel
2018-04-29 13:09 ` [RFC PATCH 6/7] MIPS: malta: enable kexec Oleksij Rempel
2018-04-29 13:09 ` [RFC PATCH 7/7] MIPS: configs: add KEXEC=y to atheros devices Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180429130907.20506-3-linux@rempel-privat.de \
    --to=linux@rempel-privat.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox