Re: Big Swap...

From: Robert Dinse (nanook@eskimo.com)
Date: Fri Jan 14 2000 - 21:07:53 EST


On Sat, 15 Jan 2000, Guest section DW wrote:

> Date: Sat, 15 Jan 2000 02:22:40 +0100
> From: Guest section DW <dwguest@win.tue.nl>
> To: Robert Dinse <nanook@eskimo.com>
> Cc: linux-kernel@vger.rutgers.edu
> Subject: Re: Big Swap...
>
> On Fri, Jan 14, 2000 at 12:47:15PM -0800, Robert Dinse wrote:
>
> [mkswap/swapon problems on a Sun]
>
> > It's on a Sun 4/670MP
> > I think it was originally installed from RedHat 4.0
>
> Well, I guess the symptoms clearly point at the following:
>
> A partition is accepted as swap space when it has a swap space signature.
> This is meant as protection, so that one wouldnt start swapping over a
> precious file system by a single typo.
>
> Where is this signature? In the last ten bytes of the first page.
> A very unfortunate design, since nobody knows how large a page is.
>
> Earlier, mkswap used the constant PAGE_SIZE, but people complained
> because this means that several binaries are required for the
> same architecture, since different models may use a different PAGE_SIZE.
> These days mkswap uses the system call getpagesize(), but as your example
> shows that is no good either, since it may return the wrong value.
>
> (To be more precise, the kernel code
>
> asmlinkage unsigned long sys_getpagesize(void)
> {
> return PAGE_SIZE; /* Possibly older binaries want 8192 on sun4's? */
> }
>
> is good enough, although the comment is a warning already, but the libc code
>
> size_t
> DEFUN_VOID(__getpagesize)
> {
> #ifdef EXEC_PAGESIZE
> return EXEC_PAGESIZE;
> #else /* No EXEC_PAGESIZE. */
> #ifdef NBPG
> #ifndef CLSIZE
> #define CLSIZE 1
> #endif /* No CLSIZE. */
> return NBPG * CLSIZE;
> #else /* No NBPG. */
> return NBPC;
> #endif /* NBPG. */
> #endif /* EXEC_PAGESIZE. */
> }
>
> does not use a system call at all, but returns EXEC_PAGESIZE which is 8192.)
> Thus, if I am not mistaken, if you change in mkswap.c, in the routine
>
> static void
> init_signature_page() {
> pagesize = getpagesize();
>
> #ifdef PAGE_SIZE
> if (pagesize != PAGE_SIZE)
> fprintf(stderr, _("Assuming pages of size %d\n"), pagesize);
> #endif
> signature_page = (int *) malloc(pagesize);
> memset(signature_page,0,pagesize);
> p = (struct swap_header_v1 *) signature_page;
> }
>
> the assignment
>
> pagesize = getpagesize();
>
> into
>
> pagesize = PAGE_SIZE;
>
> then all will be well.
>
> Thanks for pointing out this problem. Will fix mkswap.
>
> Andries

     This DID make it work! Thank you!

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jan 15 2000 - 21:00:25 EST