Application-friendly kernel interfaces
Posted Mar 29, 2007 6:02 UTC (Thu) by
ebiederm (subscriber, #35028)
In reply to:
Application-friendly kernel interfaces by jreiser
Parent article:
Application-friendly kernel interfaces
Huh?
#define PATH_TO_HUGETLBFS "/dev/hshm"
void *map_anon_hugetlb(size_t size)
{
char buffer[PATH_MAX];
int fd;
snprintf(buffer, "%s/XXXXXX", PATH_TO_HUGETLBFS);
fd = mkstemp(buffer);
if (fd < 0)
return MAP_FAILED;
unlink(buffer);
ftruncate(fd, size);
return mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
}
(
Log in to post comments)