mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] common/paritions.c: force little endian reads
@ 2012-10-11 20:28 Franck Jullien
  2012-10-11 20:28 ` [PATCH 2/2] common/partitions.c: make use of is_fat_or_mbr Franck Jullien
  2012-10-12  8:07 ` [PATCH 1/2] common/paritions.c: force little endian reads Sascha Hauer
  0 siblings, 2 replies; 4+ messages in thread
From: Franck Jullien @ 2012-10-11 20:28 UTC (permalink / raw)
  To: barebox

When reading values from a DOS disk, we need to force a little endian
reading.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 common/partitions.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/partitions.c b/common/partitions.c
index cee0a65..0e42937 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -52,8 +52,8 @@ static int disk_guess_size(struct device_d *dev, struct partition_entry *table)
 
 	for (i = 0; i < 4; i++) {
 		if (table[i].partition_start != 0) {
-			size += get_unaligned(&table[i].partition_start) - size;
-			size += get_unaligned(&table[i].partition_size);
+			size += get_unaligned_le32(&table[i].partition_start) - size;
+			size += get_unaligned_le32(&table[i].partition_size);
 		}
 	}
 
@@ -97,8 +97,8 @@ static void __maybe_unused try_dos_partition(struct block_device *blk,
 		blk->num_blocks = disk_guess_size(blk->dev, table);
 
 	for (i = 0; i < 4; i++) {
-		pentry.first_sec = get_unaligned(&table[i].partition_start);
-		pentry.size = get_unaligned(&table[i].partition_size);
+		pentry.first_sec = get_unaligned_le32(&table[i].partition_start);
+		pentry.size = get_unaligned_le32(&table[i].partition_size);
 
 		if (pentry.first_sec != 0) {
 			pd->parts[pd->used_entries].first_sec = pentry.first_sec;
-- 
1.7.1


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

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

* [PATCH 2/2] common/partitions.c: make use of is_fat_or_mbr
  2012-10-11 20:28 [PATCH 1/2] common/paritions.c: force little endian reads Franck Jullien
@ 2012-10-11 20:28 ` Franck Jullien
  2012-10-11 20:44   ` Franck Jullien
  2012-10-12  8:07 ` [PATCH 1/2] common/paritions.c: force little endian reads Sascha Hauer
  1 sibling, 1 reply; 4+ messages in thread
From: Franck Jullien @ 2012-10-11 20:28 UTC (permalink / raw)
  To: barebox

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
---
 common/partitions.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/common/partitions.c b/common/partitions.c
index 0e42937..85bca32 100644
--- a/common/partitions.c
+++ b/common/partitions.c
@@ -28,6 +28,7 @@
 #include <asm/unaligned.h>
 #include <disks.h>
 #include <dma.h>
+#include <filetype.h>
 
 struct partition {
 	uint64_t first_sec;
@@ -85,7 +86,7 @@ static void __maybe_unused try_dos_partition(struct block_device *blk,
 		goto on_error;
 	}
 
-	if ((buffer[510] != 0x55) || (buffer[511] != 0xAA)) {
+	if(is_fat_or_mbr(buffer, NULL) != filetype_mbr) {
 		dev_info(blk->dev, "No partition table found\n");
 		goto on_error;
 	}
-- 
1.7.1


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

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

* Re: [PATCH 2/2] common/partitions.c: make use of is_fat_or_mbr
  2012-10-11 20:28 ` [PATCH 2/2] common/partitions.c: make use of is_fat_or_mbr Franck Jullien
@ 2012-10-11 20:44   ` Franck Jullien
  0 siblings, 0 replies; 4+ messages in thread
From: Franck Jullien @ 2012-10-11 20:44 UTC (permalink / raw)
  To: barebox

2012/10/11 Franck Jullien <franck.jullien@gmail.com>:
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
> ---
>  common/partitions.c |    3 ++-
>  1 files changed, 2 insertions(+), 1 deletions(-)
>
> diff --git a/common/partitions.c b/common/partitions.c
> index 0e42937..85bca32 100644
> --- a/common/partitions.c
> +++ b/common/partitions.c
> @@ -28,6 +28,7 @@
>  #include <asm/unaligned.h>
>  #include <disks.h>
>  #include <dma.h>
> +#include <filetype.h>
>
>  struct partition {
>         uint64_t first_sec;
> @@ -85,7 +86,7 @@ static void __maybe_unused try_dos_partition(struct block_device *blk,
>                 goto on_error;
>         }
>
> -       if ((buffer[510] != 0x55) || (buffer[511] != 0xAA)) {
> +       if(is_fat_or_mbr(buffer, NULL) != filetype_mbr) {

Please put a space after "if" :) I resend....

>                 dev_info(blk->dev, "No partition table found\n");
>                 goto on_error;
>         }
> --
> 1.7.1
>

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

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

* Re: [PATCH 1/2] common/paritions.c: force little endian reads
  2012-10-11 20:28 [PATCH 1/2] common/paritions.c: force little endian reads Franck Jullien
  2012-10-11 20:28 ` [PATCH 2/2] common/partitions.c: make use of is_fat_or_mbr Franck Jullien
@ 2012-10-12  8:07 ` Sascha Hauer
  1 sibling, 0 replies; 4+ messages in thread
From: Sascha Hauer @ 2012-10-12  8:07 UTC (permalink / raw)
  To: Franck Jullien; +Cc: barebox

On Thu, Oct 11, 2012 at 10:28:10PM +0200, Franck Jullien wrote:
> When reading values from a DOS disk, we need to force a little endian
> reading.
> 
> Signed-off-by: Franck Jullien <franck.jullien@gmail.com>

Applied, thanks

Sascha

> ---
>  common/partitions.c |    8 ++++----
>  1 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/common/partitions.c b/common/partitions.c
> index cee0a65..0e42937 100644
> --- a/common/partitions.c
> +++ b/common/partitions.c
> @@ -52,8 +52,8 @@ static int disk_guess_size(struct device_d *dev, struct partition_entry *table)
>  
>  	for (i = 0; i < 4; i++) {
>  		if (table[i].partition_start != 0) {
> -			size += get_unaligned(&table[i].partition_start) - size;
> -			size += get_unaligned(&table[i].partition_size);
> +			size += get_unaligned_le32(&table[i].partition_start) - size;
> +			size += get_unaligned_le32(&table[i].partition_size);
>  		}
>  	}
>  
> @@ -97,8 +97,8 @@ static void __maybe_unused try_dos_partition(struct block_device *blk,
>  		blk->num_blocks = disk_guess_size(blk->dev, table);
>  
>  	for (i = 0; i < 4; i++) {
> -		pentry.first_sec = get_unaligned(&table[i].partition_start);
> -		pentry.size = get_unaligned(&table[i].partition_size);
> +		pentry.first_sec = get_unaligned_le32(&table[i].partition_start);
> +		pentry.size = get_unaligned_le32(&table[i].partition_size);
>  
>  		if (pentry.first_sec != 0) {
>  			pd->parts[pd->used_entries].first_sec = pentry.first_sec;
> -- 
> 1.7.1
> 
> 
> _______________________________________________
> 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] 4+ messages in thread

end of thread, other threads:[~2012-10-12  8:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-11 20:28 [PATCH 1/2] common/paritions.c: force little endian reads Franck Jullien
2012-10-11 20:28 ` [PATCH 2/2] common/partitions.c: make use of is_fat_or_mbr Franck Jullien
2012-10-11 20:44   ` Franck Jullien
2012-10-12  8:07 ` [PATCH 1/2] common/paritions.c: force little endian reads Sascha Hauer

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