3

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.

1 Answer 1

2

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?

1
  • 2
    And prmatta should note that not all systems use the same page size, so the correct macro constant should be used. I believe _POSIX_PAGESIZE is what you want.
    – Zan Lynx
    Apr 25, 2011 at 21:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.