kernel: mtdsplit: detect UBI partition when looking for rootfs
[openwrt.git] / target / linux / generic / files / drivers / mtd / mtdsplit / mtdsplit.h
1 /*
2  * Copyright (C) 2009-2013 Felix Fietkau <nbd@openwrt.org>
3  * Copyright (C) 2009-2013 Gabor Juhos <juhosg@openwrt.org>
4  * Copyright (C) 2012 Jonas Gorski <jogo@openwrt.org>
5  * Copyright (C) 2013 Hauke Mehrtens <hauke@hauke-m.de>
6  *
7  * This program is free software; you can redistribute it and/or modify it
8  * under the terms of the GNU General Public License version 2 as published
9  * by the Free Software Foundation.
10  *
11  */
12
13 #ifndef _MTDSPLIT_H
14 #define _MTDSPLIT_H
15
16 #define KERNEL_PART_NAME        "kernel"
17 #define ROOTFS_PART_NAME        "rootfs"
18
19 #define ROOTFS_SPLIT_NAME       "rootfs_data"
20
21 enum mtdsplit_part_type {
22         MTDSPLIT_PART_TYPE_UNK = 0,
23         MTDSPLIT_PART_TYPE_SQUASHFS,
24         MTDSPLIT_PART_TYPE_JFFS2,
25         MTDSPLIT_PART_TYPE_UBI,
26 };
27
28 #ifdef CONFIG_MTD_SPLIT
29 int mtd_get_squashfs_len(struct mtd_info *master,
30                          size_t offset,
31                          size_t *squashfs_len);
32
33 int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset,
34                            enum mtdsplit_part_type *type);
35
36 int mtd_find_rootfs_from(struct mtd_info *mtd,
37                          size_t from,
38                          size_t limit,
39                          size_t *ret_offset,
40                          enum mtdsplit_part_type *type);
41
42 #else
43 static inline int mtd_get_squashfs_len(struct mtd_info *master,
44                                        size_t offset,
45                                        size_t *squashfs_len)
46 {
47         return -ENODEV;
48 }
49
50 static inline int mtd_check_rootfs_magic(struct mtd_info *mtd, size_t offset,
51                                          enum mtdsplit_part_type *type)
52 {
53         return -EINVAL;
54 }
55
56 static inline int mtd_find_rootfs_from(struct mtd_info *mtd,
57                                        size_t from,
58                                        size_t limit,
59                                        size_t *ret_offset,
60                                        enum mtdsplit_part_type *type)
61 {
62         return -ENODEV;
63 }
64 #endif /* CONFIG_MTD_SPLIT */
65
66 #endif /* _MTDSPLIT_H */