Why I can't map memory with mmap
Valdis.Kletnieks at vt.edu
Valdis.Kletnieks at vt.edu
Mon Aug 18 12:56:13 EDT 2014
On Mon, 18 Aug 2014 16:42:33 -0000, Jeff Haran said:
> I'm pretty sure you need to pass the file descriptor of an open file or
> device as the fd (second parameter from the end). -1 is not a valid fd.
Good catch. But that should throw a different error than "resource
unavailable" - I'd expect to get EBADF back for that and it sounds like
he's getting EAGAIN back...
But yeah, that needs fixing too.
A common trick is to fd = open("/dev/zero",.... to get an fd that can
be used for mmap of anonymous space. Linux old-timers will remember
that /lib/ld-linux.so does this - with the non-obvious result that trying to
run a program that was linked against shared libraries would fail in a chroot
even if all the libraries were present, if /dev/zero wasn't in the chroot
as well....)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 848 bytes
Desc: not available
Url : http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140818/7dc4a6b9/attachment.bin
More information about the Kernelnewbies
mailing list