}
static int
-__udebug_buf_map(struct udebug_buf *buf)
+__udebug_buf_map(struct udebug_buf *buf, int fd)
{
unsigned int pad = 0;
void *ptr, *ptr2;
#endif
ptr2 = mmap(ptr, buf->head_size + buf->data_size,
- PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, buf->fd, 0);
+ PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, fd, 0);
if (ptr2 != ptr)
goto err_unmap;
ptr2 = mmap(ptr + buf->head_size + buf->data_size, buf->data_size,
- PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, buf->fd,
+ PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, fd,
buf->head_size);
if (ptr2 != ptr + buf->head_size + buf->data_size)
goto err_unmap;
{
udebug_init_page_size();
INIT_LIST_HEAD(&buf->list);
- buf->fd = fd;
buf->ring_size = ring_size;
buf->head_size = __udebug_headsize(ring_size);
buf->data_size = data_size;
if (buf->ring_size > (1U << 24) || buf->data_size > (1U << 29))
return -1;
- if (__udebug_buf_map(buf))
+ if (__udebug_buf_map(buf, fd))
return -1;
if (buf->ring_size != buf->hdr->ring_size ||
return -1;
}
+ buf->fd = fd;
+
return 0;
}
buf->data_size = size;
buf->ring_size = entries;
- if (__udebug_buf_map(buf))
+ if (__udebug_buf_map(buf, fd))
goto err_close;
buf->fd = fd;