本文介绍了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...
也许您没有对页面进行内存对齐?
Perhaps you didn't page align your memory?
这篇关于android mmap失败:参数无效(错误号22)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!