android mmap失败:参数无效(错误号22) [英] android mmap failed: invalid argument (errno 22)

查看:176
本文介绍了android mmap失败:参数无效(错误号22)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我的android设备移植/编译 androidvncserver ,但是当我以根用户身份运行它,但不断收到mmap错误.

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

令人反感的代码如下:

/* 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.

对于记录,像素= 614400,字节pp = 4.此外,/dev/graphics/fb0归根用户(group = graphics)所有,并具有660的权限.

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

推荐答案

prmatta,

错误代码22是 EINVAL .

来自 mmap() 文档,该文档告诉您...

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

EINVAL我们不喜欢开始或长度或抵消.(例如,它们太大,或未在页面边界上对齐.)

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?

这篇关于android mmap失败:参数无效(错误号22)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆