mirror of https://github.com/hak5/openwrt.git
kernel: merge two mtdpart.c patches
It does not make sense to add some code and remove is 4 patches later. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> SVN-Revision: 42673lede-17.01
parent
8e525a43b4
commit
71a03fb168
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -12,6 +12,32 @@ menuconfig MTD
|
||||
@@ -12,6 +12,33 @@ menuconfig MTD
|
||||
|
||||
if MTD
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
|||
+
|
||||
+config MTD_ROOTFS_SPLIT
|
||||
+ bool "Automatically split 'rootfs' partition for squashfs"
|
||||
+ select MTD_SPLIT
|
||||
+ default y
|
||||
+
|
||||
+config MTD_SPLIT_FIRMWARE
|
||||
|
@ -35,7 +36,7 @@
|
|||
depends on m
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -29,6 +29,7 @@
|
||||
@@ -29,9 +29,11 @@
|
||||
#include <linux/kmod.h>
|
||||
#include <linux/mtd/mtd.h>
|
||||
#include <linux/mtd/partitions.h>
|
||||
|
@ -43,7 +44,11 @@
|
|||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
@@ -45,13 +46,14 @@ struct mtd_part {
|
||||
+#include "mtdsplit.h"
|
||||
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
@@ -45,13 +47,14 @@ struct mtd_part {
|
||||
struct list_head list;
|
||||
};
|
||||
|
||||
|
@ -59,7 +64,7 @@
|
|||
/*
|
||||
* MTD methods which simply translate the effective address and pass through
|
||||
* to the _real_ device.
|
||||
@@ -534,8 +536,10 @@ out_register:
|
||||
@@ -534,8 +537,10 @@ out_register:
|
||||
return slave;
|
||||
}
|
||||
|
||||
|
@ -72,7 +77,7 @@
|
|||
{
|
||||
struct mtd_partition part;
|
||||
struct mtd_part *p, *new;
|
||||
@@ -567,21 +571,24 @@ int mtd_add_partition(struct mtd_info *m
|
||||
@@ -567,21 +572,24 @@ int mtd_add_partition(struct mtd_info *m
|
||||
end = offset + length;
|
||||
|
||||
mutex_lock(&mtd_partitions_mutex);
|
||||
|
@ -107,7 +112,7 @@
|
|||
|
||||
return ret;
|
||||
err_inv:
|
||||
@@ -591,6 +598,12 @@ err_inv:
|
||||
@@ -591,6 +599,12 @@ err_inv:
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_add_partition);
|
||||
|
||||
|
@ -120,7 +125,7 @@
|
|||
int mtd_del_partition(struct mtd_info *master, int partno)
|
||||
{
|
||||
struct mtd_part *slave, *next;
|
||||
@@ -614,6 +627,144 @@ int mtd_del_partition(struct mtd_info *m
|
||||
@@ -614,6 +628,117 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
|
@ -135,43 +140,16 @@
|
|||
+ return len;
|
||||
+}
|
||||
+
|
||||
+#define ROOTFS_SPLIT_NAME "rootfs_data"
|
||||
+
|
||||
+struct squashfs_super_block {
|
||||
+ __le32 s_magic;
|
||||
+ __le32 pad0[9];
|
||||
+ __le64 bytes_used;
|
||||
+};
|
||||
+
|
||||
+
|
||||
+static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
|
||||
+{
|
||||
+ struct squashfs_super_block sb;
|
||||
+ size_t squashfs_len;
|
||||
+ int len, ret;
|
||||
+
|
||||
+ ret = mtd_read(master, offset, sizeof(sb), &len, (void *) &sb);
|
||||
+ if (ret || (len != sizeof(sb))) {
|
||||
+ printk(KERN_ALERT "split_squashfs: error occured while reading "
|
||||
+ "from \"%s\"\n", master->name);
|
||||
+ return -EINVAL;
|
||||
+ }
|
||||
+ ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
+
|
||||
+ if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) {
|
||||
+ printk(KERN_ALERT "split_squashfs: no squashfs found in \"%s\"\n",
|
||||
+ master->name);
|
||||
+ *split_offset = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ if (le64_to_cpu((sb.bytes_used)) <= 0) {
|
||||
+ printk(KERN_ALERT "split_squashfs: squashfs is empty in \"%s\"\n",
|
||||
+ master->name);
|
||||
+ *split_offset = 0;
|
||||
+ return 0;
|
||||
+ }
|
||||
+
|
||||
+ len = (u32) le64_to_cpu(sb.bytes_used);
|
||||
+ len = mtd_pad_erasesize(master, offset, len);
|
||||
+ len = mtd_pad_erasesize(master, offset, squashfs_len);
|
||||
+ *split_offset = offset + len;
|
||||
+
|
||||
+ return 0;
|
||||
|
@ -265,7 +243,7 @@
|
|||
/*
|
||||
* This function, given a master MTD object and a partition table, creates
|
||||
* and registers slave MTD objects which are bound to the master according to
|
||||
@@ -643,6 +794,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
@@ -643,6 +768,7 @@ int add_mtd_partitions(struct mtd_info *
|
||||
mutex_unlock(&mtd_partitions_mutex);
|
||||
|
||||
add_mtd_device(&slave->mtd);
|
||||
|
|
|
@ -11,7 +11,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
|||
|
||||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -824,6 +824,30 @@ static struct mtd_part_parser *get_parti
|
||||
@@ -798,6 +798,30 @@ static struct mtd_part_parser *get_parti
|
||||
|
||||
#define put_partition_parser(p) do { module_put((p)->owner); } while (0)
|
||||
|
||||
|
@ -42,7 +42,7 @@ Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
|
|||
void register_mtd_parser(struct mtd_part_parser *p)
|
||||
{
|
||||
spin_lock(&part_parser_lock);
|
||||
@@ -897,6 +921,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
@@ -871,6 +895,38 @@ int parse_mtd_partitions(struct mtd_info
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -627,6 +627,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
@@ -628,6 +628,37 @@ int mtd_del_partition(struct mtd_info *m
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mtd_del_partition);
|
||||
|
||||
|
@ -38,7 +38,7 @@
|
|||
static inline unsigned long
|
||||
mtd_pad_erasesize(struct mtd_info *mtd, int offset, int len)
|
||||
{
|
||||
@@ -686,6 +717,10 @@ static void split_rootfs_data(struct mtd
|
||||
@@ -660,6 +691,10 @@ static void split_rootfs_data(struct mtd
|
||||
unsigned int split_size;
|
||||
int ret;
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
|||
ret = split_squashfs(master, part->offset, &split_offset);
|
||||
if (ret)
|
||||
return;
|
||||
@@ -735,6 +770,12 @@ static void split_uimage(struct mtd_info
|
||||
@@ -709,6 +744,12 @@ static void split_uimage(struct mtd_info
|
||||
|
||||
static void split_firmware(struct mtd_info *master, struct mtd_part *part)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -36,6 +36,11 @@ config MTD_UIMAGE_SPLIT
|
||||
@@ -37,6 +37,11 @@ config MTD_UIMAGE_SPLIT
|
||||
depends on MTD_SPLIT_FIRMWARE
|
||||
default y
|
||||
|
||||
|
|
|
@ -1,69 +0,0 @@
|
|||
--- a/drivers/mtd/mtdpart.c
|
||||
+++ b/drivers/mtd/mtdpart.c
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <linux/err.h>
|
||||
|
||||
#include "mtdcore.h"
|
||||
+#include "mtdsplit.h"
|
||||
|
||||
/* Our partition linked list */
|
||||
static LIST_HEAD(mtd_partitions);
|
||||
@@ -669,43 +670,16 @@ mtd_pad_erasesize(struct mtd_info *mtd,
|
||||
return len;
|
||||
}
|
||||
|
||||
-#define ROOTFS_SPLIT_NAME "rootfs_data"
|
||||
-
|
||||
-struct squashfs_super_block {
|
||||
- __le32 s_magic;
|
||||
- __le32 pad0[9];
|
||||
- __le64 bytes_used;
|
||||
-};
|
||||
-
|
||||
-
|
||||
static int split_squashfs(struct mtd_info *master, int offset, int *split_offset)
|
||||
{
|
||||
- struct squashfs_super_block sb;
|
||||
+ size_t squashfs_len;
|
||||
int len, ret;
|
||||
|
||||
- ret = mtd_read(master, offset, sizeof(sb), &len, (void *) &sb);
|
||||
- if (ret || (len != sizeof(sb))) {
|
||||
- printk(KERN_ALERT "split_squashfs: error occured while reading "
|
||||
- "from \"%s\"\n", master->name);
|
||||
- return -EINVAL;
|
||||
- }
|
||||
-
|
||||
- if (SQUASHFS_MAGIC != le32_to_cpu(sb.s_magic) ) {
|
||||
- printk(KERN_ALERT "split_squashfs: no squashfs found in \"%s\"\n",
|
||||
- master->name);
|
||||
- *split_offset = 0;
|
||||
- return 0;
|
||||
- }
|
||||
-
|
||||
- if (le64_to_cpu((sb.bytes_used)) <= 0) {
|
||||
- printk(KERN_ALERT "split_squashfs: squashfs is empty in \"%s\"\n",
|
||||
- master->name);
|
||||
- *split_offset = 0;
|
||||
- return 0;
|
||||
- }
|
||||
+ ret = mtd_get_squashfs_len(master, offset, &squashfs_len);
|
||||
+ if (ret)
|
||||
+ return ret;
|
||||
|
||||
- len = (u32) le64_to_cpu(sb.bytes_used);
|
||||
- len = mtd_pad_erasesize(master, offset, len);
|
||||
+ len = mtd_pad_erasesize(master, offset, squashfs_len);
|
||||
*split_offset = offset + len;
|
||||
|
||||
return 0;
|
||||
--- a/drivers/mtd/Kconfig
|
||||
+++ b/drivers/mtd/Kconfig
|
||||
@@ -20,6 +20,7 @@ config MTD_ROOTFS_ROOT_DEV
|
||||
|
||||
config MTD_ROOTFS_SPLIT
|
||||
bool "Automatically split 'rootfs' partition for squashfs"
|
||||
+ select MTD_SPLIT
|
||||
default y
|
||||
|
||||
config MTD_SPLIT_FIRMWARE
|
Loading…
Reference in New Issue