Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Paste
P319
Masterwork From Distant Lands
Active
Public
Actions
Authored by
markj
on Sep 24 2019, 9:15 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Flag For Later
Award Token
Tags
None
Referenced Files
F5295600: raw.txt
Sep 24 2019, 9:15 PM
2019-09-24 21:15:02 (UTC+0)
Subscribers
None
#include <sys/param.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <err.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
int
main(int argc, char **argv)
{
char template[PATH_MAX];
void *addr;
size_t sz;
int fd;
sz = 16 * 4096;
(void)snprintf(template, sizeof(template), "test.XXXXXX");
fd = mkstemp(template);
if (fd < 0)
err(1, "mkostemp");
if (fchmod(fd, 0700) < 0)
err(1, "fchmod");
if (ftruncate(fd, sz) < 0)
err(1, "ftruncate");
addr = mmap(NULL, sz, PROT_MAX(PROT_READ) | PROT_READ, MAP_SHARED, fd, 0);
if (addr == MAP_FAILED)
err(1, "mmap");
if (mlock(addr, sz) != 0)
err(1, "mlock");
if (ftruncate(fd, 0) != 0)
err(1, "ftruncate");
if (ftruncate(fd, sz) != 0)
err(1, "ftruncate");
(void)close(fd);
fd = open(template, O_EXEC);
if (fd < 0)
err(1, "open");
fexecve(fd, argv, NULL);
err(1, "fexecve");
return (0);
}
Event Timeline
markj
edited the content of this paste.
(Show Details)
Sep 24 2019, 9:15 PM
2019-09-24 21:15:02 (UTC+0)
markj
changed the title of this paste from untitled to
Masterwork From Distant Lands
.
markj
mentioned this in
D21767: Fix handling of page wirings exec_map_first_page().
.
Sep 24 2019, 9:17 PM
2019-09-24 21:17:42 (UTC+0)
Log In to Comment