Add pagesize(1)
This program is useful in constructing portable shell scripts.
This commit is contained in:
parent
0476f601b2
commit
97975ff092
1
Makefile
1
Makefile
@ -32,6 +32,7 @@ SRC = \
|
||||
mkswap.c \
|
||||
mount.c \
|
||||
mountpoint.c \
|
||||
pagesize.c \
|
||||
pidof.c \
|
||||
pivot_root.c \
|
||||
ps.c \
|
||||
|
31
pagesize.c
Normal file
31
pagesize.c
Normal file
@ -0,0 +1,31 @@
|
||||
/* See LICENSE file for copyright and license details. */
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user