From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 06/10] filetype: add new file type for 0-sized files
Date: Wed, 28 May 2025 12:50:42 +0200 [thread overview]
Message-ID: <20250528105046.3270397-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250528105046.3270397-1-a.fatoum@pengutronix.de>
We have commands and functionality like the boot code that so far
accepted either an optional argument or substituted a default in its
place if it's missing. One example is the device tree used during boot,
which is transparently replaced by the barebox internal device tree when
none was specified. To allow forcing a device-tree free boot, /dev/null
can be used in future and code can just check for filetype_empty.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
common/filetype.c | 3 ++-
include/filetype.h | 1 +
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/common/filetype.c b/common/filetype.c
index a79c8ea77e45..a7bbd8f48534 100644
--- a/common/filetype.c
+++ b/common/filetype.c
@@ -28,6 +28,7 @@ struct filetype_str {
static const struct filetype_str filetype_str[] = {
[filetype_unknown] = { "unknown", "unknown" },
+ [filetype_empty] = { "empty", "empty" },
[filetype_arm_zimage] = { "ARM Linux zImage", "arm-zimage" },
[filetype_lzo_compressed] = { "LZO compressed", "lzo" },
[filetype_lz4_compressed] = { "LZ4 compressed", "lz4" },
@@ -510,7 +511,7 @@ int file_name_detect_type_offset(const char *filename, loff_t pos, enum filetype
if (ret < 0)
goto err_out;
- *type = detect(buf, ret);
+ *type = ret ? detect(buf, ret) : filetype_empty;
ret = 0;
err_out:
diff --git a/include/filetype.h b/include/filetype.h
index 5d652f952f5b..e699815975d0 100644
--- a/include/filetype.h
+++ b/include/filetype.h
@@ -11,6 +11,7 @@
*/
enum filetype {
filetype_unknown,
+ filetype_empty,
filetype_arm_zimage,
filetype_lzo_compressed,
filetype_lz4_compressed,
--
2.39.5
next prev parent reply other threads:[~2025-05-28 12:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-28 10:50 [PATCH 00/10] ARM32: allow disabling ATAGS and DT fallback Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 01/10] arch: add new HAVE_ARCH_BOOTM_OFTREE symbol Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 02/10] bootm: enable CONFIG_BOOTM_OFTREE by default Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 03/10] ARM: lib32: disable ATAGS support " Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 04/10] kvx: bootm: enforce existence of device tree Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 05/10] bootm: booti: make device tree optional Ahmad Fatoum
2025-05-28 10:50 ` Ahmad Fatoum [this message]
2025-05-28 10:50 ` [PATCH 07/10] bootm: have bootm_get_devicetree return NULL if passed empty DT Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 08/10] bootm: make fallback to barebox internal tree optional Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 09/10] commands: oftree: add option to return device tree without fixups Ahmad Fatoum
2025-05-28 10:50 ` [PATCH 10/10] of: drop undefined fdt_get_tree declaration Ahmad Fatoum
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=20250528105046.3270397-7-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.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