From 797df5749032c2286bc7ff3a52de41fde0cdf0a5 Mon Sep 17 00:00:00 2001 From: Chris Dearman Date: Mon, 28 Apr 2008 02:12:19 -0700 Subject: [PATCH] mm: try both endianess when checking for endianess 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. Signed-off-by: Chris Dearman Signed-off-by: Ralf Baechle Acked-by: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- mm/swapfile.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mm/swapfile.c b/mm/swapfile.c index 2da149cfc9a..67051be7083 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1582,6 +1582,14 @@ asmlinkage long sys_swapon(const char __user * specialfile, int swap_flags) 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) { -- 2.20.1