aboutsummaryrefslogtreecommitdiff
path: root/external/ffspart
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2017-07-28 16:46:24 +1000
committerStewart Smith <stewart@linux.vnet.ibm.com>2017-08-01 13:57:19 +1000
commit7e89bd30e88e838f6602c2a392fa8b2738287541 (patch)
treef4f0f3495ee1969e0c278724f81ef0a3452d7bf0 /external/ffspart
parent523c6ed0f8aaca23cc733e26ff8445ce9bd2b7a9 (diff)
downloadskiboot-7e89bd30e88e838f6602c2a392fa8b2738287541.zip
skiboot-7e89bd30e88e838f6602c2a392fa8b2738287541.tar.gz
skiboot-7e89bd30e88e838f6602c2a392fa8b2738287541.tar.bz2
libflash/libffs: Don't require 'part' size to be known by callers
Currently the FFS header/TOC generation code requires that consumers know the size of their TOC beforehand. While this may be advantageous in some circumstances if there are known limitations of other software. It should not be a requirement. Knowing the size of the FFS header/TOC partially breaks the abstraction since it would require consumers of the library to be aware of/have some idea of the on flash structure and size. Future work may introduce functions to force sizes but the default behaviour should be to calculate it behind the scenes. This patch also addresses an off by one issue in checking for TOC overflow. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Reviewed-by: Samuel Mendoza-Jonas <sam@mendozajonas.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'external/ffspart')
-rw-r--r--external/ffspart/ffspart.c10
-rw-r--r--external/ffspart/test/files/03-tiny-pnor.in8
-rw-r--r--external/ffspart/test/files/03-tiny-pnor.outbin2560 -> 2560 bytes
-rw-r--r--external/ffspart/test/files/03.1-tiny-pnor-backup.in8
-rw-r--r--external/ffspart/test/files/03.1-tiny-pnor-backup.outbin2864 -> 3840 bytes
-rw-r--r--external/ffspart/test/files/04-tiny-pnor2.outbin2560 -> 2560 bytes
-rw-r--r--external/ffspart/test/results/05-hdr-overlap.err4
-rw-r--r--external/ffspart/test/results/05-hdr-overlap.out1
-rw-r--r--external/ffspart/test/results/05.1-hdr-overlap-backup.err4
-rw-r--r--external/ffspart/test/tests/03.1-tiny-pnor-backup2
10 files changed, 15 insertions, 22 deletions
diff --git a/external/ffspart/ffspart.c b/external/ffspart/ffspart.c
index 50b5861..7703477 100644
--- a/external/ffspart/ffspart.c
+++ b/external/ffspart/ffspart.c
@@ -174,17 +174,11 @@ int main(int argc, char *argv[])
goto out;
}
- /*
- * TODO: Rethink, is ffspart providing a variable TOC size useful?
- * Use 1 block for the size of the partition table...
- */
- rc = ffs_hdr_new(block_size, block_size, block_count / sides, &new_hdr);
+ rc = ffs_hdr_new(block_size, block_count / sides, &new_hdr);
if (rc) {
if (rc == FFS_ERR_BAD_SIZE) {
/* Well this check is a tad redudant now */
- fprintf(stderr, "Bad size parametres passed to libffs: "
- "size must be a multiple of block_size\n"
- "size (%u), block_size (%u) \n", block_size, block_size);
+ fprintf(stderr, "Bad parametres passed to libffs\n");
} else {
fprintf(stderr, "Error %d initialising new TOC\n", rc);
}
diff --git a/external/ffspart/test/files/03-tiny-pnor.in b/external/ffspart/test/files/03-tiny-pnor.in
index 517dc47..3c02b02 100644
--- a/external/ffspart/test/files/03-tiny-pnor.in
+++ b/external/ffspart/test/files/03-tiny-pnor.in
@@ -1,4 +1,4 @@
-ONE,0x00000300,0x00000100,EV,/dev/zero
-TWO,0x00000400,0x00000100,EF,/dev/zero
-THREE,0x00000500,0x00000100,EF,/dev/zero
-FOUR,0x00000600,0x00000100,EF,/dev/zero
+ONE,0x00400,0x00000100,EV,/dev/zero
+TWO,0x00500,0x00000100,EF,/dev/zero
+THREE,0x600,0x00000100,EF,/dev/zero
+FOUR,0x0700,0x00000100,EF,/dev/zero
diff --git a/external/ffspart/test/files/03-tiny-pnor.out b/external/ffspart/test/files/03-tiny-pnor.out
index 32e998d..e00fa5c 100644
--- a/external/ffspart/test/files/03-tiny-pnor.out
+++ b/external/ffspart/test/files/03-tiny-pnor.out
Binary files differ
diff --git a/external/ffspart/test/files/03.1-tiny-pnor-backup.in b/external/ffspart/test/files/03.1-tiny-pnor-backup.in
index 517dc47..b552750 100644
--- a/external/ffspart/test/files/03.1-tiny-pnor-backup.in
+++ b/external/ffspart/test/files/03.1-tiny-pnor-backup.in
@@ -1,4 +1,4 @@
-ONE,0x00000300,0x00000100,EV,/dev/zero
-TWO,0x00000400,0x00000100,EF,/dev/zero
-THREE,0x00000500,0x00000100,EF,/dev/zero
-FOUR,0x00000600,0x00000100,EF,/dev/zero
+ONE,0x00400,0x100,EV,/dev/zero
+TWO,0x00500,0x100,EF,/dev/zero
+THREE,0x600,0x100,EF,/dev/zero
+FOUR,0x0700,0x100,EF,/dev/zero
diff --git a/external/ffspart/test/files/03.1-tiny-pnor-backup.out b/external/ffspart/test/files/03.1-tiny-pnor-backup.out
index 85c23e3..e173e9e 100644
--- a/external/ffspart/test/files/03.1-tiny-pnor-backup.out
+++ b/external/ffspart/test/files/03.1-tiny-pnor-backup.out
Binary files differ
diff --git a/external/ffspart/test/files/04-tiny-pnor2.out b/external/ffspart/test/files/04-tiny-pnor2.out
index dad94b8..394edf0 100644
--- a/external/ffspart/test/files/04-tiny-pnor2.out
+++ b/external/ffspart/test/files/04-tiny-pnor2.out
Binary files differ
diff --git a/external/ffspart/test/results/05-hdr-overlap.err b/external/ffspart/test/results/05-hdr-overlap.err
index c0ab238..55f07c6 100644
--- a/external/ffspart/test/results/05-hdr-overlap.err
+++ b/external/ffspart/test/results/05-hdr-overlap.err
@@ -1,2 +1,2 @@
-Adding partition 'FOUR' would cause partition 'ONE' at 0x00000200 to overlap with the header
-Couldn't add entry 'FOUR' 0x00000500 for 0x00000100
+Adding partition 'THREE' would cause partition 'ONE' at 0x00000200 to overlap with the header
+Couldn't add entry 'THREE' 0x00000400 for 0x00000100
diff --git a/external/ffspart/test/results/05-hdr-overlap.out b/external/ffspart/test/results/05-hdr-overlap.out
index 9613697..dbcdcb1 100644
--- a/external/ffspart/test/results/05-hdr-overlap.out
+++ b/external/ffspart/test/results/05-hdr-overlap.out
@@ -1,5 +1,4 @@
Adding 'ONE' 0x00000200, 0x00000100
Adding 'TWO' 0x00000300, 0x00000100
Adding 'THREE' 0x00000400, 0x00000100
-Adding 'FOUR' 0x00000500, 0x00000100
Freeing hdr
diff --git a/external/ffspart/test/results/05.1-hdr-overlap-backup.err b/external/ffspart/test/results/05.1-hdr-overlap-backup.err
index 2adbf79..55f07c6 100644
--- a/external/ffspart/test/results/05.1-hdr-overlap-backup.err
+++ b/external/ffspart/test/results/05.1-hdr-overlap-backup.err
@@ -1,2 +1,2 @@
-Adding partition 'BACKUP_PART' would cause partition 'ONE' at 0x00000200 to overlap with the header
-Failed to create backup part
+Adding partition 'THREE' would cause partition 'ONE' at 0x00000200 to overlap with the header
+Couldn't add entry 'THREE' 0x00000400 for 0x00000100
diff --git a/external/ffspart/test/tests/03.1-tiny-pnor-backup b/external/ffspart/test/tests/03.1-tiny-pnor-backup
index a622ca6..3065c86 100644
--- a/external/ffspart/test/tests/03.1-tiny-pnor-backup
+++ b/external/ffspart/test/tests/03.1-tiny-pnor-backup
@@ -2,7 +2,7 @@
touch $DATA_DIR/$CUR_TEST.gen
-run_binary "./ffspart" "-b -s 0x100 -c 10 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
+run_binary "./ffspart" "-b -s 0x100 -c 15 -i $DATA_DIR/$CUR_TEST.in -p $DATA_DIR/$CUR_TEST.gen"
if [ "$?" -ne 0 ] ; then
fail_test
fi