android mmap 失败:参数无效(errno 22)
我正在为我的 Android 设备移植/编译 androidvncserver ,但是当我运行它时(作为 root)我不断收到 mmap 错误。
有问题的代码如下所示:
/* 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);
}
我正在寻找有关如何进一步调试此代码的想法。
根据记录,像素 = 614400,字节数 = 4。另外,/dev/graphics/fb0 属于 root (group=graphics),权限为 660。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
prmatta,
错误代码 22 是
EINVAL
。从
mmap()
文档告诉您......也许您没有对内存进行页面对齐?
prmatta,
Error code 22 is
EINVAL
.From the
mmap()
documentation that tells you...Perhaps you didn't page align your memory?