Hello,

Consider the following program

#include <stdio.h>
#include <stdint.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/random.h>
#include <unistd.h>

int main(int argc, char *argv[])
{
    int success = 0;
    int fd = open("/dev/urandom", O_RDONLY);
    if (fd != -1)
    {
        int entropy;
        if (ioctl(fd, RNDGETENTCNT, &entropy) == -1)
        {
            printf("ioctl failed");
        } else {
            printf("ioctl ok");
        }
        close(fd);
    }
    else
    {
        printf("open failed");
    }
    return 0;
}


When I run this program with qemu-x86_64-static I got the error

Unsupported ioctl: cmd=0xffffffff80045200
ioctl failed

But it works fine if the program is executed without qemu.

I compiled the program in a x86_64 box with gcc.

Am I doing something wrong?

I've patched qemu to forward the iocl with RNDGETENTCNT  to the host and it
worked as expected. Can someone explain me why this does not work out of
the box?

Thanks.

-- 
Marco A L Barbosa
http://malbarbo.pro.br
--

Reply via email to