mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] block/partition/msdos: detect AIX formatted disks even without 55aa
@ 2013-01-25 15:05 Philippe De Muyter
  2013-01-25 15:36 ` Andreas Mohr
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe De Muyter @ 2013-01-25 15:05 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, akpm, olh, Philippe De Muyter

AIX formatted disks do not always have the MSDOS 55aa signature.
This happens e.g. for unbootable AIX disks.

Up to now, such disks were not recognized as AIX disks, because of the
missing 55aa.  Fix that by inverting the two tests.  Let's first
check for the AIX magic strings, and only if that fails check for
the MSDOS magic word.

Signed-off-by: Philippe De Muyter <phdm@macqel.be>
---
 block/partitions/msdos.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/block/partitions/msdos.c b/block/partitions/msdos.c
index 8752a5d..4b31ed7 100644
--- a/block/partitions/msdos.c
+++ b/block/partitions/msdos.c
@@ -455,14 +455,15 @@ int msdos_partition(struct parsed_partitions *state)
 	data = read_part_sector(state, 0, &sect);
 	if (!data)
 		return -1;
-	if (!msdos_magic_present(data + 510)) {
+
+	if (aix_magic_present(state, data)) {
 		put_dev_sector(sect);
+		strlcat(state->pp_buf, " [AIX]", PAGE_SIZE);
 		return 0;
 	}
 
-	if (aix_magic_present(state, data)) {
+	if (!msdos_magic_present(data + 510)) {
 		put_dev_sector(sect);
-		strlcat(state->pp_buf, " [AIX]", PAGE_SIZE);
 		return 0;
 	}
 
-- 
1.7.1


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

* Re: [PATCH] block/partition/msdos: detect AIX formatted disks even without 55aa
  2013-01-25 15:05 [PATCH] block/partition/msdos: detect AIX formatted disks even without 55aa Philippe De Muyter
@ 2013-01-25 15:36 ` Andreas Mohr
  2013-01-25 15:51   ` [PATCH v2] " Philippe De Muyter
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Mohr @ 2013-01-25 15:36 UTC (permalink / raw)
  To: Philippe De Muyter; +Cc: linux-kernel, axboe, akpm, olh, Philippe De Muyter

Hi,

IMHO that patch would better have a small but important one-liner comment
(one cannot rely on people always making use of SCM history functionality,
thereby this would be at risk of getting reversed accidentally eventually).

E.g.

/* Note order! (some AIX disks, e.g. unbootable kind, have no MSDOS 55aa) */

	if (aix_magic_present(state, data)) {
.
.
.


Apart from that: nice compat catch!

HTH,

Andreas Mohr

-- 
GNU/Linux. It's not the software that's free, it's you.

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

* [PATCH v2] block/partition/msdos: detect AIX formatted disks even without 55aa
  2013-01-25 15:36 ` Andreas Mohr
@ 2013-01-25 15:51   ` Philippe De Muyter
  0 siblings, 0 replies; 3+ messages in thread
From: Philippe De Muyter @ 2013-01-25 15:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: axboe, akpm, olh, Philippe De Muyter

AIX formatted disks do not always have the MSDOS 55aa signature.
This happens e.g. for unbootable AIX disks.

Up to now, such disks were not recognized as AIX disks, because of the
missing 55aa.  Fix that by inverting the two tests.  Let's first
check for the AIX magic strings, and only if that fails check for
the MSDOS magic word.

Signed-off-by: Philippe De Muyter <phdm@macqel.be>
---
 block/partitions/msdos.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

v2: add a comment to avoid accidental removal of the tests order
    (suggested by Andreas Mohr <andi@lisas.de>)

diff --git a/block/partitions/msdos.c b/block/partitions/msdos.c
index 8752a5d..7681cd2 100644
--- a/block/partitions/msdos.c
+++ b/block/partitions/msdos.c
@@ -455,14 +455,19 @@ int msdos_partition(struct parsed_partitions *state)
 	data = read_part_sector(state, 0, &sect);
 	if (!data)
 		return -1;
-	if (!msdos_magic_present(data + 510)) {
+
+	/*
+	 * Note order! (some AIX disks, e.g. unbootable kind,
+	 * have no MSDOS 55aa)
+	 */
+	if (aix_magic_present(state, data)) {
 		put_dev_sector(sect);
+		strlcat(state->pp_buf, " [AIX]", PAGE_SIZE);
 		return 0;
 	}
 
-	if (aix_magic_present(state, data)) {
+	if (!msdos_magic_present(data + 510)) {
 		put_dev_sector(sect);
-		strlcat(state->pp_buf, " [AIX]", PAGE_SIZE);
 		return 0;
 	}
 
-- 
1.7.1


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

end of thread, other threads:[~2013-01-25 15:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-25 15:05 [PATCH] block/partition/msdos: detect AIX formatted disks even without 55aa Philippe De Muyter
2013-01-25 15:36 ` Andreas Mohr
2013-01-25 15:51   ` [PATCH v2] " Philippe De Muyter

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

all inboxes | Powered by JetHome®