* [U-Boot] [PATCH] disk: part_dos: check harder for partition table.
@ 2013-03-26 9:06 egbert.eich at googlemail.com
2013-03-26 13:04 ` [U-Boot] [PATCH] disk/part_dos: " Egbert Eich
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: egbert.eich at googlemail.com @ 2013-03-26 9:06 UTC (permalink / raw)
To: u-boot
From: Egbert Eich <eich@suse.com>
Devices that used to have a whole disk FAT filesystem but got then
partitioned will most likely still have a FAT or FAT32 signature
in the first sector as this sector does not get overwritten by
a partitioning tool (otherwise the tool would risk to kill the mbr).
The current partition search algorithm will erronosly detect such
a device as a raw FAT device.
Instead of looking for the FAT or FAT32 signatures immediately we
use the same algorithm as used by the Linux kernel and first check
for a valid boot indicator flag on each of the 4 partitions.
If the value of this flag is invalid for the first entry we then
do the raw partition check.
If the flag for any higher partition is wrong we assume the device
is neiter a MBR nor PBR device.
Signed-off-by: Egbert Eich <eich@suse.com>
---
disk/part_dos.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 37087a6..8a23495 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -74,13 +74,23 @@ static void print_one_part(dos_partition_t *p, int ext_part_sector,
static int test_block_type(unsigned char *buffer)
{
+ int slot;
+ struct dos_partition *p;
+
if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
return (-1);
} /* no DOS Signature at all */
- if (strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0 ||
- strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],"FAT32",5)==0) {
- return DOS_PBR; /* is PBR */
+ p = ( struct dos_partition *)&buffer[DOS_PART_TBL_OFFSET];
+ for (slot = 0; slot < 3; slot++) {
+ if (p->boot_ind != 0 && p->boot_ind != 0x80) {
+ if (!slot &&
+ (strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0 ||
+ strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],"FAT32",5)==0)) {
+ return DOS_PBR; /* is PBR */
+ } else
+ return -1;
+ }
}
return DOS_MBR; /* Is MBR */
}
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] disk/part_dos: check harder for partition table
2013-03-26 9:06 [U-Boot] [PATCH] disk: part_dos: check harder for partition table egbert.eich at googlemail.com
@ 2013-03-26 13:04 ` Egbert Eich
2013-03-26 14:05 ` [U-Boot] [PATCH] disk: part_dos: " Wolfgang Denk
2013-04-09 15:46 ` [U-Boot] [Patch v2] disk/part_dos: " Egbert Eich
2 siblings, 0 replies; 5+ messages in thread
From: Egbert Eich @ 2013-03-26 13:04 UTC (permalink / raw)
To: u-boot
From: Egbert Eich <eich@suse.com>
Devices that used to have a whole disk FAT filesystem but got then
partitioned will most likely still have a FAT or FAT32 signature
in the first sector as this sector does not get overwritten by
a partitioning tool (otherwise the tool would risk to kill the mbr).
The current partition search algorithm will erronously detect such
a device as a raw FAT device.
Instead of looking for the FAT or FAT32 signatures immediately we
use the same algorithm as used by the Linux kernel and first check
for a valid boot indicator flag on each of the 4 partitions.
If the value of this flag is invalid for the first entry we then
do the raw partition check.
If the flag for any higher partition is wrong we assume the device
is neiter a MBR nor PBR device.
v2: Coding style cleanup.
Signed-off-by: Egbert Eich <eich@suse.com>
---
disk/part_dos.c | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 37087a6..3fc8564 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -74,13 +74,25 @@ static void print_one_part(dos_partition_t *p, int ext_part_sector,
static int test_block_type(unsigned char *buffer)
{
+ int slot;
+ struct dos_partition *p;
+
if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
return (-1);
} /* no DOS Signature at all */
- if (strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0 ||
- strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],"FAT32",5)==0) {
- return DOS_PBR; /* is PBR */
+ p = (struct dos_partition *)&buffer[DOS_PART_TBL_OFFSET];
+ for (slot = 0; slot < 3; slot++) {
+ if (p->boot_ind != 0 && p->boot_ind != 0x80) {
+ if (!slot &&
+ (strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],
+ "FAT", 3) == 0 ||
+ strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],
+ "FAT32", 5) == 0)) {
+ return DOS_PBR; /* is PBR */
+ } else
+ return -1;
+ }
}
return DOS_MBR; /* Is MBR */
}
--
1.7.7
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [PATCH] disk: part_dos: check harder for partition table.
2013-03-26 9:06 [U-Boot] [PATCH] disk: part_dos: check harder for partition table egbert.eich at googlemail.com
2013-03-26 13:04 ` [U-Boot] [PATCH] disk/part_dos: " Egbert Eich
@ 2013-03-26 14:05 ` Wolfgang Denk
2013-04-09 15:46 ` [U-Boot] [Patch v2] disk/part_dos: " Egbert Eich
2 siblings, 0 replies; 5+ messages in thread
From: Wolfgang Denk @ 2013-03-26 14:05 UTC (permalink / raw)
To: u-boot
Dear egbert.eich at googlemail.com,
In message <1364288765-2637-1-git-send-email-egbert.eich@gmail.com> you wrote:
> From: Egbert Eich <eich@suse.com>
>
> Devices that used to have a whole disk FAT filesystem but got then
> partitioned will most likely still have a FAT or FAT32 signature
> in the first sector as this sector does not get overwritten by
> a partitioning tool (otherwise the tool would risk to kill the mbr).
Patch version missing. Patch change history missing. Checkpatch
errors and warnings. Please fix!
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
People are always a lot more complicated than you think. It's very
important to remember that. - Terry Pratchett, _Truckers_
^ permalink raw reply [flat|nested] 5+ messages in thread
* [U-Boot] [Patch v2] disk/part_dos: check harder for partition table
2013-03-26 9:06 [U-Boot] [PATCH] disk: part_dos: check harder for partition table egbert.eich at googlemail.com
2013-03-26 13:04 ` [U-Boot] [PATCH] disk/part_dos: " Egbert Eich
2013-03-26 14:05 ` [U-Boot] [PATCH] disk: part_dos: " Wolfgang Denk
@ 2013-04-09 15:46 ` Egbert Eich
2013-05-02 16:07 ` [U-Boot] [U-Boot, " Tom Rini
2 siblings, 1 reply; 5+ messages in thread
From: Egbert Eich @ 2013-04-09 15:46 UTC (permalink / raw)
To: u-boot
From: Egbert Eich <eich@suse.com>
Devices that used to have a whole disk FAT filesystem but got then
partitioned will most likely still have a FAT or FAT32 signature
in the first sector as this sector does not get overwritten by
a partitioning tool (otherwise the tool would risk to kill the mbr).
The current partition search algorithm will erronously detects such
a device as a raw FAT device.
Instead of looking for the FAT or FAT32 signatures immediately we
use the same algorithm as used by the Linux kernel and first check
for a valid boot indicator flag on each of the 4 partitions.
If the value of this flag is invalid for the first entry we then
do the raw partition check.
If the flag for any higher partition is wrong we assume the device
is neiter a MBR nor PBR device.
Signed-off-by: Egbert Eich <eich@suse.com>
---
Changes for v2:
- Coding style fixes.
disk/part_dos.c | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 37087a6..ab984cd 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -74,13 +74,26 @@ static void print_one_part(dos_partition_t *p, int ext_part_sector,
static int test_block_type(unsigned char *buffer)
{
+ int slot;
+ struct dos_partition *p;
+
if((buffer[DOS_PART_MAGIC_OFFSET + 0] != 0x55) ||
(buffer[DOS_PART_MAGIC_OFFSET + 1] != 0xaa) ) {
return (-1);
} /* no DOS Signature at all */
- if (strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],"FAT",3)==0 ||
- strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],"FAT32",5)==0) {
- return DOS_PBR; /* is PBR */
+ p = (struct dos_partition *)&buffer[DOS_PART_TBL_OFFSET];
+ for (slot = 0; slot < 3; slot++) {
+ if (p->boot_ind != 0 && p->boot_ind != 0x80) {
+ if (!slot &&
+ (strncmp((char *)&buffer[DOS_PBR_FSTYPE_OFFSET],
+ "FAT", 3) == 0 ||
+ strncmp((char *)&buffer[DOS_PBR32_FSTYPE_OFFSET],
+ "FAT32", 5) == 0)) {
+ return DOS_PBR; /* is PBR */
+ } else {
+ return -1;
+ }
+ }
}
return DOS_MBR; /* Is MBR */
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [U-Boot] [U-Boot, v2] disk/part_dos: check harder for partition table
2013-04-09 15:46 ` [U-Boot] [Patch v2] disk/part_dos: " Egbert Eich
@ 2013-05-02 16:07 ` Tom Rini
0 siblings, 0 replies; 5+ messages in thread
From: Tom Rini @ 2013-05-02 16:07 UTC (permalink / raw)
To: u-boot
On Tue, Apr 09, 2013 at 05:46:14AM -0000, egbert.eich at gmail.com wrote:
> From: Egbert Eich <eich@suse.com>
>
> Devices that used to have a whole disk FAT filesystem but got then
> partitioned will most likely still have a FAT or FAT32 signature
> in the first sector as this sector does not get overwritten by
> a partitioning tool (otherwise the tool would risk to kill the mbr).
>
> The current partition search algorithm will erronously detects such
> a device as a raw FAT device.
>
> Instead of looking for the FAT or FAT32 signatures immediately we
> use the same algorithm as used by the Linux kernel and first check
> for a valid boot indicator flag on each of the 4 partitions.
> If the value of this flag is invalid for the first entry we then
> do the raw partition check.
> If the flag for any higher partition is wrong we assume the device
> is neiter a MBR nor PBR device.
>
> Signed-off-by: Egbert Eich <eich@suse.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130502/5ebcb908/attachment.pgp>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-05-02 16:07 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-26 9:06 [U-Boot] [PATCH] disk: part_dos: check harder for partition table egbert.eich at googlemail.com
2013-03-26 13:04 ` [U-Boot] [PATCH] disk/part_dos: " Egbert Eich
2013-03-26 14:05 ` [U-Boot] [PATCH] disk: part_dos: " Wolfgang Denk
2013-04-09 15:46 ` [U-Boot] [Patch v2] disk/part_dos: " Egbert Eich
2013-05-02 16:07 ` [U-Boot] [U-Boot, " Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox