Check for a valid pagesize in mkswap(8)

This commit is contained in:
sin 2013-10-29 15:54:12 +00:00
parent 9c37575961
commit 41769b976a

View File

@ -45,7 +45,12 @@ main(int argc, char *argv[])
if (argc < 1) if (argc < 1)
usage(); usage();
pagesize = sysconf(_SC_PAGESIZE);
if (pagesize <= 0) {
pagesize = sysconf(_SC_PAGE_SIZE); pagesize = sysconf(_SC_PAGE_SIZE);
if (pagesize <= 0)
enprintf(EXIT_FAILURE, "can't determine pagesize\n");
}
fd = open(argv[0], O_RDWR); fd = open(argv[0], O_RDWR);
if (fd < 0) if (fd < 0)