[OpenWrt-Devel] [PATCH 2/3] kernel: mtdsplit: detect UBI partition when looking for rootfs
Rafał Miłecki
zajec5 at gmail.com
Fri Jan 29 06:10:39 EST 2016
This allows mtdsplit parsers work with UBI which is very popular on
NAND flases.
Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
---
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c | 6 ++++++
target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h | 1 +
2 files changed, 7 insertions(+)
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
index 4f6b46e..9a330df 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c
@@ -22,6 +22,8 @@
#include "mtdsplit.h"
+#define UBI_EC_MAGIC 0x55424923 /* UBI# */
+
struct squashfs_super_block {
__le32 s_magic;
__le32 pad0[9];
@@ -93,6 +95,10 @@ int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset,
if (type)
*type = MTDSPLIT_PART_TYPE_JFFS2;
return 0;
+ } else if (be32_to_cpu(magic) == UBI_EC_MAGIC) {
+ if (type)
+ *type = MTDSPLIT_PART_TYPE_UBI;
+ return 0;
}
return -EINVAL;
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
index b757758..42841ef 100644
--- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
+++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.h
@@ -22,6 +22,7 @@ enum mtdsplit_part_type {
MTDSPLIT_PART_TYPE_UNK = 0,
MTDSPLIT_PART_TYPE_SQUASHFS,
MTDSPLIT_PART_TYPE_JFFS2,
+ MTDSPLIT_PART_TYPE_UBI,
};
#ifdef CONFIG_MTD_SPLIT
--
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
More information about the openwrt-devel
mailing list