SUSv2 marked getpagesize() LEGACY, and POSIX.1-2001 dropped it. Some systems do not even have it (e.g. HP-UX). Use the more portable sysconf(_SC_PAGESIZE) call instead. Signed-off-by: Guillem Jover <guillem@xxxxxxxxxxx> --- disk-utils/fsck.cramfs.c | 2 +- disk-utils/mkfs.cramfs.c | 2 +- disk-utils/mkswap.c | 19 ++++++++++--------- mount/swapon.c | 2 +- sys-utils/ipcs.c | 2 +- tests/helpers/test_sysinfo.c | 2 +- 6 files changed, 15 insertions(+), 14 deletions(-) diff --git a/disk-utils/fsck.cramfs.c b/disk-utils/fsck.cramfs.c index 649aef0..c4bb50b 100644 --- a/disk-utils/fsck.cramfs.c +++ b/disk-utils/fsck.cramfs.c @@ -705,7 +705,7 @@ int main(int argc, char **argv) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); - page_size = getpagesize(); + page_size = sysconf(_SC_PAGESIZE); if (argc) progname = argv[0]; diff --git a/disk-utils/mkfs.cramfs.c b/disk-utils/mkfs.cramfs.c index 4ffa908..4741440 100644 --- a/disk-utils/mkfs.cramfs.c +++ b/disk-utils/mkfs.cramfs.c @@ -745,7 +745,7 @@ int main(int argc, char **argv) int c; cramfs_is_big_endian = HOST_IS_BIG_ENDIAN; /* default is to use host order */ - blksize = getpagesize(); + blksize = sysconf(_SC_PAGESIZE); total_blocks = 0; if (argc) { diff --git a/disk-utils/mkswap.c b/disk-utils/mkswap.c index 1205acd..031ae54 100644 --- a/disk-utils/mkswap.c +++ b/disk-utils/mkswap.c @@ -130,16 +130,17 @@ is_sparc64(void) { /* * The definition of the union swap_header uses the kernel constant PAGE_SIZE. * Unfortunately, on some architectures this depends on the hardware model, and - * can only be found at run time -- we use getpagesize(), so that we do not - * need separate binaries e.g. for sun4, sun4c/d/m and sun4u. + * can only be found at run time -- we use sysconf(_SC_PAGESIZE), so that we do + * not need separate binaries e.g. for sun4, sun4c/d/m and sun4u. * - * Even more unfortunately, getpagesize() does not always return the right - * information. For example, libc4, libc5 and glibc 2.0 do not use the system - * call but invent a value themselves (EXEC_PAGESIZE or NBPG * CLSIZE or NBPC), - * and thus it may happen that e.g. on a sparc kernel PAGE_SIZE=4096 and - * getpagesize() returns 8192. + * Previously getpagesize() was used instead of sysconf(_SC_PAGESIZE), and it + * did not always return the right information. For example, libc4, libc5 and + * glibc 2.0 do not use the system call but invent a value themselves + * (EXEC_PAGESIZE or NBPG * CLSIZE or NBPC), and thus it may have happened + * that e.g. on a sparc kernel PAGE_SIZE=4096 and getpagesize() returned 8192. * - * What to do? Let us allow the user to specify the pagesize explicitly. + * For this reason the user was allowed to specify the pagesize explicitly, + * which we keep allowing for compatibility. * */ static int user_pagesize; @@ -150,7 +151,7 @@ struct swap_header_v1 *p; static void init_signature_page(void) { - int kernel_pagesize = pagesize = getpagesize(); + int kernel_pagesize = pagesize = sysconf(_SC_PAGESIZE); if (user_pagesize) { if ((user_pagesize & (user_pagesize-1)) || diff --git a/mount/swapon.c b/mount/swapon.c index 55933b1..eac638d 100644 --- a/mount/swapon.c +++ b/mount/swapon.c @@ -414,7 +414,7 @@ swapon_checks(const char *special) warnx(_("%s: last_page 0x%08llx is larger" " than actual size of swapspace"), special, swapsize); - } else if (getpagesize() != pagesize) { + } else if (sysconf(_SC_PAGESIZE) != pagesize) { if (fixpgsz) { warnx(_("%s: swap format pagesize does not match."), special); diff --git a/sys-utils/ipcs.c b/sys-utils/ipcs.c index 55d5c80..44355ff 100644 --- a/sys-utils/ipcs.c +++ b/sys-utils/ipcs.c @@ -271,7 +271,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"), - getpagesize() / 1024 * (unsigned long long) shminfo.shmall); + sysconf(_SC_PAGESIZE) / 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 8ce1fe7..d0c0fef 100644 --- a/tests/helpers/test_sysinfo.c +++ b/tests/helpers/test_sysinfo.c @@ -52,7 +52,7 @@ hlp_endianness(void) int hlp_pagesize(void) { - printf("%d\n", getpagesize()); + printf("%d\n", sysconf(_SC_PAGESIZE)); return 0; } -- 1.6.4.3 -- 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