util-linux patch vs. PAGE_SIZE on powerpc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

the loop-AES patch for util-linux uses the PAGE_SIZE definition
which is normally available through asm/page.h. Unfortunately
this is no longer the case for powerpc. There PAGE_SIZE is only
defined inside #ifdef __KERNEL__ and so causes builds to fail.

>From what I picked up, the glibc function getpagesize() can be
used instead. The manpage is a bit discouraging and notes that
availability varies depending on the architecture, but since
getpagesize() is already used in other parts of upstream mount/
I would guess that it is not actually so bad in practice. :-)

I'm attaching the patch that I'm including in Debian
loop-aes-utils to fix the build on powerpc. Comments welcome -
Does that change look okay to you, or is there a better way?

cheers,
Max

-- 
http://buildd.debian.org/fetch.php?&pkg=loop-aes-utils&ver=2.12r-12&arch=powerpc&stamp=1153245109&file=log&as=raw
--- mount/swapon.c~	2006-07-18 21:22:03.000000000 +0200
+++ mount/swapon.c	2006-07-18 21:22:46.000000000 +0200
@@ -323,6 +323,7 @@
 prepare_encrypted_swap(const char *partition, char *loop, char *encryption)
 {
 	int x, y, fd, ffd;
+	int page_size;
 	sha512_context s;
 	unsigned char b[4096], multiKeyBits[65][32];
 	char *a[10], *apiName;
@@ -366,7 +367,8 @@
 		fprintf(stderr, _("swapon: unable to open swap device %s\n"), partition);
 		goto errout0;
 	}
-	fseek(f, (long)PAGE_SIZE, SEEK_SET);
+	page_size = getpagesize()
+	fseek(f, (long)page_size, SEEK_SET);
 	sha512_init(&s);
 	for(x = 0; x < 10; x++) {
 		if(fread(&b[0], sizeof(b), 1, f) != 1) break;
@@ -385,7 +387,7 @@
 			unsigned char h[64];
 			int x,y,z;
 		} j;
-		if(fseek(f, (long)PAGE_SIZE, SEEK_SET)) break;
+		if(fseek(f, (long)page_size, SEEK_SET)) break;
 		memcpy(&j.h[0], &s.sha_out[0], 64);
 		gettimeofday(&j.tv, NULL);
 		j.y = y;
@@ -444,7 +446,7 @@
 		memset(&multiKeyBits[0][0], 0, sizeof(multiKeyBits));
 		return 0;
 	}
-	loopinfo.lo_offset = PAGE_SIZE;
+	loopinfo.lo_offset = page_size;
 	/* single-key hash */
 	sha512_hash_buffer(&b[0], 64+32, &loopinfo.lo_encrypt_key[0], sizeof(loopinfo.lo_encrypt_key));
 	/* multi-key hash */

[Index of Archives]     [Kernel]     [Linux Crypto]     [Gnu Crypto]     [Gnu Classpath]     [Netfilter]     [Bugtraq]
  Powered by Linux