mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] partitions: dos: add partuuid string for logical partitions
@ 2016-05-09 10:55 Uwe Kleine-König
  2016-05-10  6:14 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Uwe Kleine-König @ 2016-05-09 10:55 UTC (permalink / raw)
  To: barebox

Commit bc31d85c6e23 ("cdev: Add partuuid string to struct cdev") added
partuuid strings for dos partitions but only for the (up to) four
primary partitions. Do the same for the logical partitions. Their
numbers start at 5 independently of the number of available primary
partitions.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 common/partitions/dos.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index e0cb35627d33..5f08e253ee59 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -117,11 +117,12 @@ static int dos_get_disk_signature(struct param_d *p, void *_priv)
 }
 
 static void dos_extended_partition(struct block_device *blk, struct partition_desc *pd,
-		struct partition *partition)
+		struct partition *partition, uint32_t signature)
 {
 	uint8_t *buf = dma_alloc(SECTOR_SIZE);
 	uint32_t ebr_sector = partition->first_sec;
 	struct partition_entry *table = (struct partition_entry *)&buf[0x1be];
+	unsigned partno = 5;
 
 	while (pd->used_entries < ARRAY_SIZE(pd->parts)) {
 		int rc, i;
@@ -153,7 +154,11 @@ static void dos_extended_partition(struct block_device *blk, struct partition_de
 			get_unaligned_le32(&table[0].partition_start);
 		pd->parts[n].size = get_unaligned_le32(&table[0].partition_size);
 		pd->parts[n].dos_partition_type = table[0].type;
+		if (signature)
+			sprintf(pd->parts[n].partuuid, "%08x-%02u",
+				signature, partno);
 		pd->used_entries++;
+		partno++;
 
 		/* the second entry defines the start of the next ebr if != 0 */
 		if (get_unaligned_le32(&table[1].partition_start))
@@ -231,7 +236,7 @@ static void dos_partition(void *buf, struct block_device *blk,
 	}
 
 	if (extended_partition)
-		dos_extended_partition(blk, pd, extended_partition);
+		dos_extended_partition(blk, pd, extended_partition, signature);
 
 	dsp = xzalloc(sizeof(*dsp));
 	dsp->blk = blk;
-- 
2.8.0.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] partitions: dos: add partuuid string for logical partitions
  2016-05-09 10:55 [PATCH] partitions: dos: add partuuid string for logical partitions Uwe Kleine-König
@ 2016-05-10  6:14 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2016-05-10  6:14 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox

On Mon, May 09, 2016 at 12:55:08PM +0200, Uwe Kleine-König wrote:
> Commit bc31d85c6e23 ("cdev: Add partuuid string to struct cdev") added
> partuuid strings for dos partitions but only for the (up to) four
> primary partitions. Do the same for the logical partitions. Their
> numbers start at 5 independently of the number of available primary
> partitions.
> 
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  common/partitions/dos.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)

Applied, thanks

Sascha

> 
> diff --git a/common/partitions/dos.c b/common/partitions/dos.c
> index e0cb35627d33..5f08e253ee59 100644
> --- a/common/partitions/dos.c
> +++ b/common/partitions/dos.c
> @@ -117,11 +117,12 @@ static int dos_get_disk_signature(struct param_d *p, void *_priv)
>  }
>  
>  static void dos_extended_partition(struct block_device *blk, struct partition_desc *pd,
> -		struct partition *partition)
> +		struct partition *partition, uint32_t signature)
>  {
>  	uint8_t *buf = dma_alloc(SECTOR_SIZE);
>  	uint32_t ebr_sector = partition->first_sec;
>  	struct partition_entry *table = (struct partition_entry *)&buf[0x1be];
> +	unsigned partno = 5;
>  
>  	while (pd->used_entries < ARRAY_SIZE(pd->parts)) {
>  		int rc, i;
> @@ -153,7 +154,11 @@ static void dos_extended_partition(struct block_device *blk, struct partition_de
>  			get_unaligned_le32(&table[0].partition_start);
>  		pd->parts[n].size = get_unaligned_le32(&table[0].partition_size);
>  		pd->parts[n].dos_partition_type = table[0].type;
> +		if (signature)
> +			sprintf(pd->parts[n].partuuid, "%08x-%02u",
> +				signature, partno);
>  		pd->used_entries++;
> +		partno++;
>  
>  		/* the second entry defines the start of the next ebr if != 0 */
>  		if (get_unaligned_le32(&table[1].partition_start))
> @@ -231,7 +236,7 @@ static void dos_partition(void *buf, struct block_device *blk,
>  	}
>  
>  	if (extended_partition)
> -		dos_extended_partition(blk, pd, extended_partition);
> +		dos_extended_partition(blk, pd, extended_partition, signature);
>  
>  	dsp = xzalloc(sizeof(*dsp));
>  	dsp->blk = blk;
> -- 
> 2.8.0.rc3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-10  6:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-05-09 10:55 [PATCH] partitions: dos: add partuuid string for logical partitions Uwe Kleine-König
2016-05-10  6:14 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox