lkml.org 
[lkml]   [2000]   [Jan]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: 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

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:55    [W:0.281 / U:0.104 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site