diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-19 09:31:30 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2024-02-20 11:46:30 +0100 |
commit | 1018f6c694f0561028af3496530316e9db32e3a4 (patch) | |
tree | af8414168118d57cab6bb7f572709c4e47321997 /common/partitions/dos.c | |
parent | 4accc68d2d5155074455109f5889f8c00b30eafc (diff) | |
download | barebox-1018f6c694f0561028af3496530316e9db32e3a4.tar.gz barebox-1018f6c694f0561028af3496530316e9db32e3a4.tar.xz |
partition: allocate struct partition_desc in parser
Allocate struct partition_desc in parser rather than in the core. Doing
so allows the efi/dos partition code to embed the struct partition_desc
is a efi/dos specific struct type.
Link: https://lore.barebox.org/20240219083140.2713047-3-s.hauer@pengutronix.de
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/partitions/dos.c')
-rw-r--r-- | common/partitions/dos.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/partitions/dos.c b/common/partitions/dos.c index 56ec1e3f48..01a251201e 100644 --- a/common/partitions/dos.c +++ b/common/partitions/dos.c @@ -171,8 +171,7 @@ out: * It seems at least on ARM this routine cannot use temp. stack space for the * sector. So, keep the malloc/free. */ -static void dos_partition(void *buf, struct block_device *blk, - struct partition_desc *pd) +static struct partition_desc *dos_partition(void *buf, struct block_device *blk) { struct partition_entry *table; struct partition pentry; @@ -181,6 +180,7 @@ static void dos_partition(void *buf, struct block_device *blk, int i; struct disk_signature_priv *dsp; uint32_t signature = get_unaligned_le32(buf + 0x1b8); + struct partition_desc *pd; if (signature) sprintf(blk->cdev.diskuuid, "%08x", signature); @@ -189,6 +189,8 @@ static void dos_partition(void *buf, struct block_device *blk, table = (struct partition_entry *)&buffer[446]; + pd = xzalloc(sizeof(*pd)); + for (i = 0; i < 4; i++) { int n; @@ -244,10 +246,18 @@ static void dos_partition(void *buf, struct block_device *blk, dev_add_param_uint32(blk->dev, "nt_signature", dos_set_disk_signature, dos_get_disk_signature, &dsp->signature, "%08x", dsp); + + return pd; +} + +static void dos_partition_free(struct partition_desc *pd) +{ + free(pd); } static struct partition_parser dos = { .parse = dos_partition, + .partition_free = dos_partition_free, .type = filetype_mbr, }; |