mprotect.c revision 0
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi * Use is subject to license terms.
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi#pragma ident "@(#)mprotect.c 1.6 05/08/04 SMI"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomitypedef volatile char vchar_t;
98bc2ecdbfd4f2f20c3a5e96ae445072fbe22223Aki Tuomitypedef struct {
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomistatic int optr = 0;
03c6532fe7aa3ddae23c99ff6bec78d8dd2e8165Aki Tuomistatic int optw = 0;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomistatic int opts = 0;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomistatic int optt = 0;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomistatic int anon = 0;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomistatic int foo = 0;
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi " [-f file-to-map (default %s)]\n"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi " [-l mapping-length (default %d)]\n"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi " [-r] (read a byte from each page)\n"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi " [-w] (write a byte on each page)\n"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi " [-s] (use MAP_SHARED)\n"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi " [-t] (touch each page after restoring permissions)\n"
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi "notes: measures mprotect()\n",
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi (void) sprintf(lm_header, "%8s %5s", "size", "flags");
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi return (-1);
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi seg = (vchar_t *)mmap(NULL, lm_optB * optl, PROT_READ | PROT_WRITE,
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi return (-1);
4036c1ca99d2c517f68a5b67a419ae7fdfd45300Aki Tuomi for (i = 0; i < lm_optB; i++) {