aboutsummaryrefslogtreecommitdiff
path: root/libflash
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2018-03-15 16:58:20 +1100
committerStewart Smith <stewart@linux.ibm.com>2018-04-09 03:45:23 -0500
commit14ed1a2d7611503f8ddcf2b5e003c98b9a57f360 (patch)
tree163b4c349595310e5bc2a9e39a5018c6cff005f5 /libflash
parent0673f6282422e5cb26f79c986228c863b1ec8a36 (diff)
downloadskiboot-14ed1a2d7611503f8ddcf2b5e003c98b9a57f360.zip
skiboot-14ed1a2d7611503f8ddcf2b5e003c98b9a57f360.tar.gz
skiboot-14ed1a2d7611503f8ddcf2b5e003c98b9a57f360.tar.bz2
libflash/libffs: Remove the 'sides' from the FFS TOC generation code
It turns out this code was messy and not all that reliable. Doing it at the library level adds complexity to the library and restrictions to the caller. A simpler approach can be achived with the just instantiating multiple ffs_header structures pointing to different parts of the same file. Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.ibm.com>
Diffstat (limited to 'libflash')
-rw-r--r--libflash/ffs.h2
-rw-r--r--libflash/libffs.c77
-rw-r--r--libflash/libffs.h3
3 files changed, 4 insertions, 78 deletions
diff --git a/libflash/ffs.h b/libflash/ffs.h
index 72ba257..8fc5580 100644
--- a/libflash/ffs.h
+++ b/libflash/ffs.h
@@ -207,7 +207,6 @@ struct __ffs_hdr {
* @block_size: Size of block on device (in bytes)
* @block_count: Number of blocks on device.
* @backup The backup partition
- * @side The ffs header for the other side
* @entries: List of partition entries
*/
struct ffs_hdr {
@@ -218,7 +217,6 @@ struct ffs_hdr {
uint32_t block_count;
struct ffs_entry *part;
struct ffs_entry *backup;
- struct ffs_hdr *side;
struct list_head entries;
};
diff --git a/libflash/libffs.c b/libflash/libffs.c
index e115e42..c32b453 100644
--- a/libflash/libffs.c
+++ b/libflash/libffs.c
@@ -448,10 +448,6 @@ static void __hdr_free(struct ffs_hdr *hdr)
list_del(&ent->list);
free(ent);
}
- if (hdr->side) {
- hdr->side->side = NULL;
- ffs_hdr_free(hdr->side);
- }
}
int ffs_hdr_free(struct ffs_hdr *hdr)
@@ -615,10 +611,8 @@ static int __ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry)
return 0;
}
-int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry, unsigned int side)
+int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry)
{
- int rc;
-
/*
* Refuse to add anything after BACKUP_PART has been added, not
* sure why this is needed anymore
@@ -626,36 +620,7 @@ int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry, unsigned int sid
if (hdr->backup)
return FLASH_ERR_PARM_ERROR;
- if (side == 0) { /* Sideless... */
- rc = __ffs_entry_add(hdr, entry);
- if (!rc && hdr->side) {
- struct ffs_entry *other_ent;
-
- /*
- * A rather sneaky copy is hidden here.
- * It doesn't make sense for a consumer to be aware that structures
- * must be duplicated. The entries list in the header could have
- * been an array of pointers and no copy would have been required.
- */
- other_ent = calloc(1, sizeof (struct ffs_entry));
- if (!other_ent)
- /* TODO Remove the added entry from side 1 */
- return FLASH_ERR_PARM_ERROR;
- memcpy(other_ent, entry, sizeof(struct ffs_entry));
- rc = __ffs_entry_add(hdr->side, other_ent);
- if (rc)
- /* TODO Remove the added entry from side 1 */
- free(other_ent);
- }
- } else if (side == 1) {
- rc = __ffs_entry_add(hdr, entry);
- } else if (side == 2 && hdr->side) {
- rc = __ffs_entry_add(hdr->side, entry);
- } else {
- rc = FLASH_ERR_PARM_ERROR;
- }
-
- return rc;
+ return __ffs_entry_add(hdr, entry);
}
/* This should be done last! */
@@ -687,29 +652,6 @@ int ffs_hdr_create_backup(struct ffs_hdr *hdr)
hdr->backup = backup;
- /* Do we try to roll back completely if that fails or leave what we've added? */
- if (hdr->side && hdr->base == 0)
- rc = ffs_hdr_create_backup(hdr->side);
-
- return rc;
-}
-
-int ffs_hdr_add_side(struct ffs_hdr *hdr)
-{
- int rc;
-
- /* Only a second side for now */
- if (hdr->side)
- return FLASH_ERR_PARM_ERROR;
-
- rc = ffs_hdr_new(hdr->block_size, hdr->block_count, &hdr->side);
- if (rc)
- return rc;
-
- hdr->side->base = hdr->block_size * hdr->block_count;
- /* Sigh */
- hdr->side->side = hdr;
-
return rc;
}
@@ -725,16 +667,6 @@ int ffs_hdr_finalise(struct blocklevel_device *bl, struct ffs_hdr *hdr)
if (num_entries == 0)
return FFS_ERR_BAD_SIZE;
- if (hdr->side) {
- struct ffs_entry *other_side;
- /* TODO: Change the hard coded 0x8000 */
- rc = ffs_entry_new("OTHER_SIDE", hdr->side->base, 0x8000, &other_side);
- if (rc)
- return rc;
- list_add_tail(&hdr->entries, &other_side->list);
- num_entries++;
- }
-
real_hdr = malloc(ffs_hdr_raw_size(num_entries));
if (!real_hdr)
return FLASH_ERR_MALLOC_FAILED;
@@ -785,11 +717,6 @@ int ffs_hdr_finalise(struct blocklevel_device *bl, struct ffs_hdr *hdr)
rc = blocklevel_write(bl, hdr->backup->base, real_hdr,
ffs_hdr_raw_size(num_entries));
}
- if (rc)
- goto out;
-
- if (hdr->side && hdr->base == 0)
- rc = ffs_hdr_finalise(bl, hdr->side);
out:
free(real_hdr);
return rc;
diff --git a/libflash/libffs.h b/libflash/libffs.h
index 4c74aed..05db033 100644
--- a/libflash/libffs.h
+++ b/libflash/libffs.h
@@ -151,10 +151,11 @@ int ffs_entry_user_set(struct ffs_entry *ent, struct ffs_entry_user *user);
int ffs_entry_set_act_size(struct ffs_entry *ent, uint32_t actual_size);
-int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry, unsigned int side);
struct ffs_entry_user ffs_entry_user_get(struct ffs_entry *ent);
+int ffs_entry_add(struct ffs_hdr *hdr, struct ffs_entry *entry);
+
int ffs_hdr_create_backup(struct ffs_hdr *hdr);
int ffs_hdr_finalise(struct blocklevel_device *bl, struct ffs_hdr *hdr);