diff options
author | Rafał Miłecki <zajec5@gmail.com> | 2016-02-01 12:41:41 +0000 |
---|---|---|
committer | Rafał Miłecki <zajec5@gmail.com> | 2016-02-01 12:41:41 +0000 |
commit | e1491b341b212000bc26f68b55d9a060b9c48625 (patch) | |
tree | cb58aca4643c016200b5a1ab1d3b297e7f226f7f /target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c | |
parent | 704473864eac18db32ac5a6d96b8eb36c556351b (diff) | |
download | upstream-e1491b341b212000bc26f68b55d9a060b9c48625.tar.gz upstream-e1491b341b212000bc26f68b55d9a060b9c48625.tar.bz2 upstream-e1491b341b212000bc26f68b55d9a060b9c48625.zip |
kernel: mtdsplit: modify rootfs helpers to provide partition type
Our mtdsplit parsers may want to create partition with name choice based
on partition file system (e.g. SquashFS vs. JFFS2). This patch allows
passing extra argument pointing to variable that will be set properly.
Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
SVN-Revision: 48598
Diffstat (limited to 'target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c')
-rw-r--r-- | target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c index 162739f472..4f6b46e28b 100644 --- a/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c +++ b/target/linux/generic/files/drivers/mtd/mtdsplit/mtdsplit.c @@ -70,7 +70,8 @@ static ssize_t mtd_next_eb(struct mtd_info *mtd, size_t offset) return mtd_rounddown_to_eb(offset, mtd) + mtd->erasesize; } -int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset) +int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset, + enum mtdsplit_part_type *type) { u32 magic; size_t retlen; @@ -84,25 +85,32 @@ int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset) if (retlen != sizeof(magic)) return -EIO; - if (le32_to_cpu(magic) != SQUASHFS_MAGIC && - magic != 0x19852003) - return -EINVAL; + if (le32_to_cpu(magic) == SQUASHFS_MAGIC) { + if (type) + *type = MTDSPLIT_PART_TYPE_SQUASHFS; + return 0; + } else if (magic == 0x19852003) { + if (type) + *type = MTDSPLIT_PART_TYPE_JFFS2; + return 0; + } - return 0; + return -EINVAL; } EXPORT_SYMBOL_GPL(mtd_check_rootfs_magic); int mtd_find_rootfs_from(struct mtd_info *mtd, size_t from, size_t limit, - size_t *ret_offset) + size_t *ret_offset, + enum mtdsplit_part_type *type) { size_t offset; int err; for (offset = from; offset < limit; offset = mtd_next_eb(mtd, offset)) { - err = mtd_check_rootfs_magic(mtd, offset); + err = mtd_check_rootfs_magic(mtd, offset, type); if (err) continue; |