LWN.net Logo

Application-friendly kernel interfaces

Application-friendly kernel interfaces

Posted Mar 29, 2007 3:07 UTC (Thu) by jreiser (subscriber, #11027)
Parent article: Application-friendly kernel interfaces

It's not possible to do normal reads and writes from this filesystem [hugetlbfs] ...

and that makes hugetlbfs less than a filesystem. Hugetlbfs is a hack, and it is hard to use. Hugetlbfs is so hard to use that our editor could not find an actual working example to cite. Show me the code!


(Log in to post comments)

Application-friendly kernel interfaces

Posted Mar 29, 2007 6:02 UTC (Thu) by ebiederm (subscriber, #35028) [Link]

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);
}

Application-friendly kernel interfaces

Posted Mar 29, 2007 15:16 UTC (Thu) by vmole (subscriber, #111) [Link]

snprintf(buffer, "%s/XXXXXX", PATH_TO_HUGETLBFS);

So much for working code... ;-)

Application-friendly kernel interfaces

Posted Mar 29, 2007 15:38 UTC (Thu) by ebiederm (subscriber, #35028) [Link]

Yea yea.

snprintf(buffer, sizoef(buffer), ....);

Application-friendly kernel interfaces

Posted Mar 29, 2007 16:02 UTC (Thu) by vmole (subscriber, #111) [Link]

Strike 2! [Steve readies for the next pitch.]

Yeah yeah, I know that code written for forums like this is at best psuedo-code. Hell, I blew it just the other day, so I'm hardly the one to be picking on you, but I was amused by the "Show me the code" - "huh?" sequence.

Perhaps we can get away with claiming "Well, it was a actually a debugging test for the reader". Right, that's it.

Copyright © 2008, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds
Powered by Rackspace Managed Hosting.