[PATCH 06/10] filetype: add new file type for 0-sized files
Ahmad Fatoum
a.fatoum at pengutronix.de
Wed May 28 03:50:42 PDT 2025
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 at 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
More information about the barebox
mailing list