Skip to contentSkip to conversation

Try both endianess when checking for endianess.

PATCH New Ralf Baechle 1 participant 1 message Feb 25, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Try both endianess when checking for endianess.

From: Chris Dearman <[email protected]>

When checking for the swap header try byteswapping the endianess dependent fields to allow the swap partition to be shared between big & little endian systems.

 mm/swapfile.c |    8 ++++++++
 1 file changed, 8 insertions(+)
mm/swapfile.c +8 -0
Index: linux-queue/mm/swapfile.c
===================================================================
@@ -1551,6 +1551,14 @@ asmlinkage long sys_swapon(const char __
 		error = -EINVAL;
 		goto bad_swap;
 	case 2:
+		/* swap partition endianess hack... */
+		if (swab32(swap_header->info.version) == 1) {
+			swab32s(&swap_header->info.version);
+			swab32s(&swap_header->info.last_page);
+			swab32s(&swap_header->info.nr_badpages);
+			for (i = 0; i < swap_header->info.nr_badpages; i++)
+				swab32s(&swap_header->info.badpages[i]);
+		}
 		/* Check the swap header's sub-version and the size of
                    the swap file and bad block lists */
 		if (swap_header->info.version != 1) {