rootfs_split: Allow using MTDPART_OFS_APPEND macro for offset of rootfs.

Use offset from struct mtd_part instead of struct mtd_partition for defining
the new partitions. This enables the usage of MTDPART_OFS_APPEND macro in
struct mtd_partition.

Signed-off-by: Jochen Friedrich <jochen@scram.de>

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@26705 3c298f89-4303-0410-b956-a3cf2f4a3e73
master
Felix Fietkau 2011-04-17 18:32:28 +00:00
parent 6431cd0853
commit d49cb1d62f
7 changed files with 43 additions and 29 deletions

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -512,6 +514,155 @@ out_register: @@ -512,6 +514,157 @@ out_register:
return slave; return slave;
} }
@ -93,10 +93,12 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int split_offset = 0; + int split_offset = 0;
+ int ret; + int ret;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -114,7 +116,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)
@ -193,7 +195,7 @@
/* /*
* This function, given a master MTD object and a partition table, creates * 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 * and registers slave MTD objects which are bound to the master according to
@@ -527,14 +678,29 @@ int add_mtd_partitions(struct mtd_info * @@ -527,14 +680,29 @@ int add_mtd_partitions(struct mtd_info *
{ {
struct mtd_part *slave; struct mtd_part *slave;
uint64_t cur_offset = 0; uint64_t cur_offset = 0;
@ -226,7 +228,7 @@
cur_offset = slave->offset + slave->mtd.size; cur_offset = slave->offset + slave->mtd.size;
} }
@@ -542,6 +708,32 @@ int add_mtd_partitions(struct mtd_info * @@ -542,6 +710,32 @@ int add_mtd_partitions(struct mtd_info *
} }
EXPORT_SYMBOL(add_mtd_partitions); EXPORT_SYMBOL(add_mtd_partitions);

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -502,6 +504,150 @@ out_register: @@ -502,6 +504,152 @@ out_register:
return slave; return slave;
} }
@ -92,10 +92,12 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int split_offset = 0; + int split_offset = 0;
+ int ret; + int ret;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -113,7 +115,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)
@ -188,7 +190,7 @@
/* /*
* This function, given a master MTD object and a partition table, creates * 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 * and registers slave MTD objects which are bound to the master according to
@@ -517,7 +663,7 @@ int add_mtd_partitions(struct mtd_info * @@ -517,7 +665,7 @@ int add_mtd_partitions(struct mtd_info *
{ {
struct mtd_part *slave; struct mtd_part *slave;
uint64_t cur_offset = 0; uint64_t cur_offset = 0;
@ -197,7 +199,7 @@
printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
@@ -525,6 +671,21 @@ int add_mtd_partitions(struct mtd_info * @@ -525,6 +673,21 @@ int add_mtd_partitions(struct mtd_info *
slave = add_one_partition(master, parts + i, i, cur_offset); slave = add_one_partition(master, parts + i, i, cur_offset);
if (!slave) if (!slave)
return -ENOMEM; return -ENOMEM;
@ -219,7 +221,7 @@
cur_offset = slave->offset + slave->mtd.size; cur_offset = slave->offset + slave->mtd.size;
} }
@@ -532,6 +693,32 @@ int add_mtd_partitions(struct mtd_info * @@ -532,6 +695,32 @@ int add_mtd_partitions(struct mtd_info *
} }
EXPORT_SYMBOL(add_mtd_partitions); EXPORT_SYMBOL(add_mtd_partitions);

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -503,6 +505,150 @@ out_register: @@ -503,6 +505,152 @@ out_register:
return slave; return slave;
} }
@ -92,10 +92,12 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int split_offset = 0; + int split_offset = 0;
+ int ret; + int ret;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -113,7 +115,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)
@ -188,7 +190,7 @@
/* /*
* This function, given a master MTD object and a partition table, creates * 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 * and registers slave MTD objects which are bound to the master according to
@@ -518,7 +664,7 @@ int add_mtd_partitions(struct mtd_info * @@ -518,7 +666,7 @@ int add_mtd_partitions(struct mtd_info *
{ {
struct mtd_part *slave; struct mtd_part *slave;
uint64_t cur_offset = 0; uint64_t cur_offset = 0;
@ -197,7 +199,7 @@
printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name); printk(KERN_NOTICE "Creating %d MTD partitions on \"%s\":\n", nbparts, master->name);
@@ -526,6 +672,21 @@ int add_mtd_partitions(struct mtd_info * @@ -526,6 +674,21 @@ int add_mtd_partitions(struct mtd_info *
slave = add_one_partition(master, parts + i, i, cur_offset); slave = add_one_partition(master, parts + i, i, cur_offset);
if (!slave) if (!slave)
return -ENOMEM; return -ENOMEM;
@ -219,7 +221,7 @@
cur_offset = slave->offset + slave->mtd.size; cur_offset = slave->offset + slave->mtd.size;
} }
@@ -533,6 +694,32 @@ int add_mtd_partitions(struct mtd_info * @@ -533,6 +696,32 @@ int add_mtd_partitions(struct mtd_info *
} }
EXPORT_SYMBOL(add_mtd_partitions); EXPORT_SYMBOL(add_mtd_partitions);

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -524,6 +526,150 @@ out_register: @@ -524,6 +526,152 @@ out_register:
return slave; return slave;
} }
@ -92,10 +92,12 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int split_offset = 0; + int split_offset = 0;
+ int ret; + int ret;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -113,7 +115,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -618,6 +620,153 @@ int mtd_del_partition(struct mtd_info *m @@ -618,6 +620,155 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -92,9 +92,11 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int ret, split_offset = 0; + int ret, split_offset = 0;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -112,7 +114,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -636,6 +638,153 @@ int mtd_del_partition(struct mtd_info *m @@ -636,6 +638,155 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -92,9 +92,11 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int ret, split_offset = 0; + int ret, split_offset = 0;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -112,7 +114,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)

View File

@ -37,7 +37,7 @@
/* /*
* MTD methods which simply translate the effective address and pass through * MTD methods which simply translate the effective address and pass through
@@ -636,6 +638,153 @@ int mtd_del_partition(struct mtd_info *m @@ -636,6 +638,155 @@ int mtd_del_partition(struct mtd_info *m
} }
EXPORT_SYMBOL_GPL(mtd_del_partition); EXPORT_SYMBOL_GPL(mtd_del_partition);
@ -92,9 +92,11 @@
+{ +{
+ struct mtd_partition *dpart; + struct mtd_partition *dpart;
+ struct mtd_part *slave = NULL; + struct mtd_part *slave = NULL;
+ struct mtd_part *spart;
+ int ret, split_offset = 0; + int ret, split_offset = 0;
+ +
+ ret = split_squashfs(master, part->offset, &split_offset); + spart = PART(rpart);
+ ret = split_squashfs(master, spart->offset, &split_offset);
+ if (ret) + if (ret)
+ return ret; + return ret;
+ +
@ -112,7 +114,7 @@
+ dpart->name = (unsigned char *)&dpart[1]; + dpart->name = (unsigned char *)&dpart[1];
+ strcpy(dpart->name, ROOTFS_SPLIT_NAME); + strcpy(dpart->name, ROOTFS_SPLIT_NAME);
+ +
+ dpart->size -= split_offset - dpart->offset; + dpart->size = rpart->size - (split_offset - spart->offset);
+ dpart->offset = split_offset; + dpart->offset = split_offset;
+ +
+ if (dpart == NULL) + if (dpart == NULL)