[klibc] Add swap support to fstype, second version

David Härdeman david at 2gen.com
Mon Feb 6 23:25:40 PST 2006


On Mon, Feb 06, 2006 at 07:10:15PM -0800, H. Peter Anvin wrote:
>David Härdeman wrote:
>>+/* The super block is the last block in the first page */
>>+#define SWAP_OFFSET		((PAGE_SIZE - BLOCK_SIZE) / BLOCK_SIZE)
>
>This is a bit confusing... on some architectures, PAGE_SIZE is 
>undefined, because it's variable.  To get the page size, one has to do 
>getpagesize(), but it's not even clear to me that that is the right thing.
>
>I've applied the patch, but could you perhaps try to find out how this 
>is supposed to work on architectures where page size is variable?

I grabbed it from include/linux/swap.h which contains:

union swap_header {
        struct {
                char reserved[PAGE_SIZE - 10];
                char magic[10]; /* SWAP-SPACE or SWAPSPACE2 */
        } magic;

swap.h also includes <asm/page.h>, presumably to get the page size. So 
I'm guessing that the compile-time page-size is used on architectures 
with variable sizes, but I'll double-check the code to verify that.

Now, I didn't see any architectures for which PAGE_SIZE is undefined at 
compile-time...which one(s) are you referring to?

Re,
David



More information about the klibc mailing list