diff --git a/Makefile b/Makefile index cc09ded..753b227 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,7 @@ SRC = \ mkswap.c \ mount.c \ mountpoint.c \ + pagesize.c \ pidof.c \ pivot_root.c \ ps.c \ diff --git a/pagesize.c b/pagesize.c new file mode 100644 index 0000000..ef70628 --- /dev/null +++ b/pagesize.c @@ -0,0 +1,31 @@ +/* See LICENSE file for copyright and license details. */ +#include +#include +#include +#include "util.h" + +static void +usage(void) +{ + eprintf("usage: %s\n", argv0); +} + +int +main(int argc, char *argv[]) +{ + long pagesz; + + ARGBEGIN { + default: + usage(); + } ARGEND; + + pagesz = sysconf(_SC_PAGESIZE); + if (pagesz < 0) { + pagesz = sysconf(_SC_PAGE_SIZE); + if (pagesz < 0) + enprintf(EXIT_FAILURE, "can't determine pagesize\n"); + } + printf("%ld\n", pagesz); + return EXIT_SUCCESS; +}