开发者

android mmap failed: invalid argument (errno 22)

I was porting/compiling androidvncserver for my android device, but when I run it (as root) I keep getting mmap errors.

The offending code looks like this:

/* Android does not use /dev/fb0. */
#define FB_DEVICE "/dev/graphics/fb0"

if ((fbfd = open(FB_DEVICE, O_RDONLY)) == -1)
{
    printf("cannot 开发者_如何学编程open fb device %s\n", FB_DEVICE);
    exit(EXIT_FAILURE);
}

<SNIP>

fbmmap = mmap(NULL, pixels * bytespp, PROT_READ, MAP_SHARED, fbfd, 0);
if (fbmmap == MAP_FAILED)
{
    printf("mmap failed errno = %d\n", errno);
    exit(EXIT_FAILURE);
}

I am looking for thoughts on how to debug this further.

For the record, pixels=614400 and bytespp=4. Also, /dev/graphics/fb0 is owned by root (group=graphics), and has permissions of 660.


prmatta,

Error code 22 is EINVAL.

From the mmap() documentation that tells you...

EINVAL We don't like start or length or offset. (E.g., they are too large, or not aligned on a page boundary.)

Perhaps you didn't page align your memory?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜