From: Sascha Hauer <s.hauer@pengutronix.de>
To: Hubert Feurstein <h.feurstein@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 1/2] common/filetype: move partition-table detection into own function
Date: Mon, 29 Apr 2013 09:35:48 +0200 [thread overview]
Message-ID: <20130429073548.GK20989@pengutronix.de> (raw)
In-Reply-To: <1366361165-28803-1-git-send-email-h.feurstein@gmail.com>
Hi Hubert,
On Fri, Apr 19, 2013 at 10:46:04AM +0200, Hubert Feurstein wrote:
> Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
> ---
> common/filetype.c | 41 ++++++++++++++++++++++++-----------------
> include/filetype.h | 1 +
> 2 files changed, 25 insertions(+), 17 deletions(-)
Modified this slightly to the below and applied both.
Thanks
Sascha
8<------------------------------------------------------
From c06956e15f8fb32d46e479950719c30bae57e5bb Mon Sep 17 00:00:00 2001
From: Hubert Feurstein <h.feurstein@gmail.com>
Date: Fri, 19 Apr 2013 10:46:04 +0200
Subject: [PATCH] common/filetype: move partition-table detection into own
function
Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
common/filetype.c | 36 ++++++++++++++++++++++++------------
include/filetype.h | 1 +
2 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/common/filetype.c b/common/filetype.c
index 8652f1d..1ff3dd2 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -151,6 +151,28 @@ enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec)
return filetype_mbr;
}
+enum filetype file_detect_partition_table(const void *_buf, size_t bufsize)
+{
+ const u8 *buf8 = _buf;
+ enum filetype type;
+
+ if (bufsize < 512)
+ return filetype_unknown;
+
+ /*
+ * EFI GPT need to be detected before MBR otherwise
+ * we will detect a MBR
+ */
+ if (bufsize >= 520 && is_gpt_valid(buf8))
+ return filetype_gpt;
+
+ type = is_fat_or_mbr(buf8, NULL);
+ if (type != filetype_unknown)
+ return type;
+
+ return filetype_unknown;
+}
+
enum filetype file_detect_type(const void *_buf, size_t bufsize)
{
const u32 *buf = _buf;
@@ -204,21 +226,11 @@ enum filetype file_detect_type(const void *_buf, size_t bufsize)
if (bufsize < 512)
return filetype_unknown;
- /*
- * EFI GPT need to be detected before MBR otherwise
- * we will detect a MBR
- */
- if (bufsize >= 520 && is_gpt_valid(buf8))
- return filetype_gpt;
-
- type = is_fat_or_mbr(buf8, NULL);
+ type = file_detect_partition_table(_buf, bufsize);
if (type != filetype_unknown)
return type;
- if (bufsize < 1536)
- return filetype_unknown;
-
- if (buf16[512 + 28] == le16_to_cpu(0xef53))
+ if (bufsize >= 1536 && buf16[512 + 28] == le16_to_cpu(0xef53))
return filetype_ext;
return filetype_unknown;
diff --git a/include/filetype.h b/include/filetype.h
index 78ca5d2..ee777ac 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -31,6 +31,7 @@ enum filetype {
const char *file_type_to_string(enum filetype f);
const char *file_type_to_short_string(enum filetype f);
+enum filetype file_detect_partition_table(const void *_buf, size_t bufsize);
enum filetype file_detect_type(const void *_buf, size_t bufsize);
enum filetype file_name_detect_type(const char *filename);
enum filetype is_fat_or_mbr(const unsigned char *sector, unsigned long *bootsec);
--
1.8.2.rc2
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2013-04-29 7:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 8:46 Hubert Feurstein
2013-04-19 8:46 ` [PATCH 2/2] common/partition: check only for partition table types Hubert Feurstein
2013-04-19 15:46 ` [PATCH 1/2] common/filetype: move partition-table detection into own function Jean-Christophe PLAGNIOL-VILLARD
2013-04-29 7:35 ` Sascha Hauer [this message]
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=20130429073548.GK20989@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=h.feurstein@gmail.com \
/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