I'm trying to port LRMI to minix3 and I've some problems with mmap. As
there's no mmap in Minix I used mapmem function from XServer. When I
try to map /dev/zero I got errno 25(not a typewriter). I don't have
problems with mapping /dev/mem.

Have anyone idea what's wrong?

Here's mapmem function:

static void *mapmem(int fd, off_t base, size_t size, int readonly)
size_t bufsize;
int o, r, t_errno;
char *abuf, *buf, **bpp;
struct mapreq mapreq;


/* Add a page for alignment and room a point to the start of the
* malloced buffer.
bufsize= PAGE_SIZE+size + sizeof(abuf);
abuf= malloc(bufsize);
if (abuf == NULL)
FatalError("mapmem: unable to allocate %u bytes", bufsize);
#if 0
ErrorF("mapmem: got buffer size 0x%x at %p\n", bufsize, abuf);
buf= abuf + sizeof(abuf);
o= (unsigned)buf % PAGE_SIZE;
if (o)
buf= (char *)buf + (PAGE_SIZE-o);

mapreq.base= buf;
mapreq.size= size;
mapreq.offset= base;
mapreq.readonly= readonly;
r= ioctl(fd, MIOCMAP, &mapreq);
if (r == -1)
t_errno= errno;
buf= NULL;
ErrorF("MIOCMAP failed: %d\n", t_errno);
errno= t_errno;
if (buf)
bpp= (char **)buf;
bpp[-1]= abuf;
return buf;

And how I try to use it:

//fd_zero is opened /dev/zero device
realmem = mapmem(fd_zero, (void *)0x10000, 0x40000, _IOC_INOUT);