[patch] util-linux-ng use getpagesize()

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

 



getpagesize() is said to be more portable than sysconf(_SC_PAGESIZE)
to anything Linux. 

this patch helps klibc porting effort as the sysconf
multiplex API is not supported there.

also remove comment of the switch to sysconf in mkswap.c.

Signed-off-by: maximilian attems <max@xxxxxxx>

diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c
index 2d082ef..aeb766f 100644
--- a/disk-utils/fsck.cramfs.c
+++ b/disk-utils/fsck.cramfs.c
@@ -675,7 +675,7 @@ int main(int argc, char **argv)
 	int start = 0;
 	size_t length;
 
-	page_size = sysconf(_SC_PAGESIZE);
+	page_size = getpagesize();
 
 	if (argc)
 		progname = argv[0];
diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c
index 04d8ab8..7882e33 100644
--- a/disk-utils/mkfs.cramfs.c
+++ b/disk-utils/mkfs.cramfs.c
@@ -735,7 +735,7 @@ int main(int argc, char **argv)
 	u32 crc = crc32(0L, Z_NULL, 0);
 	int c;
 
-	blksize = sysconf(_SC_PAGESIZE);
+	blksize = getpagesize();
 	total_blocks = 0;
 
 	if (argc) {
diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c
index f7dbdf3..9d1ca3d 100644
--- a/disk-utils/mkswap.c
+++ b/disk-utils/mkswap.c
@@ -132,10 +132,6 @@ is_sparc64(void) {
  *
  * What to do? Let us allow the user to specify the pagesize explicitly.
  *
- * Update 05-Feb-2007 (kzak):
- *      - use sysconf(_SC_PAGESIZE) to be consistent with the rest of
- *        util-linux code.  It is the standardized and preferred way of
- *        querying page size.
  */
 static int user_pagesize;
 static int pagesize;
@@ -145,7 +141,7 @@ struct swap_header_v1 *p;
 static void
 init_signature_page(void) {
 
-	int kernel_pagesize = pagesize = (int) sysconf(_SC_PAGESIZE);
+	int kernel_pagesize = pagesize = getpagesize();
 
 	if (user_pagesize) {
 		if ((user_pagesize & (user_pagesize-1)) ||
diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c
index 1b3400c..3738d89 100644
--- a/sys-utils/ipcs.c
+++ b/sys-utils/ipcs.c
@@ -281,7 +281,7 @@ void do_shm (char format)
 		printf (_("max seg size (kbytes) = %lu\n"),
 			(unsigned long) (shminfo.shmmax >> 10));
 		printf (_("max total shared memory (kbytes) = %llu\n"),
-			sysconf(_SC_PAGESIZE) / 1024 * (unsigned long long) shminfo.shmall);
+			getpagesize() / 1024 * (unsigned long long) shminfo.shmall);
 		printf (_("min seg size (bytes) = %lu\n"),
 			(unsigned long) shminfo.shmmin);
 		return;
diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c
index 00ee252..4b71955 100644
--- a/tests/helpers/test_sysinfo.c
+++ b/tests/helpers/test_sysinfo.c
@@ -36,7 +36,7 @@ hlp_wordsize(void)
 int
 hlp_pagesize(void)
 {
-	printf("%d\n", (int) sysconf(_SC_PAGESIZE));
+	printf("%d\n", getpagesize());
 	return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux