Пример #1
0
static int
tapdisk_ctl_conn_init(struct tapdisk_ctl_conn *conn, size_t bufsz)
{
	int prot, flags, err;

	memset(conn, 0, sizeof(*conn));
	conn->out.event_id = -1;
	conn->in.event_id  = -1;

	prot  = PROT_READ|PROT_WRITE;
	flags = MAP_ANONYMOUS|MAP_PRIVATE;

	conn->out.buf = mmap(NULL, bufsz, prot, flags, -1, 0);
	if (conn->out.buf == MAP_FAILED) {
		conn->out.buf = NULL;
		err = -ENOMEM;
		goto fail;
	}
	conn->out.bufsz = page_align(bufsz);

	return 0;

fail:
	tapdisk_ctl_conn_uninit(conn);
	return err;
}
Пример #2
0
static int
tapdisk_ctl_conn_init(struct tapdisk_ctl_conn *conn, size_t bufsz)
{
	int err;

	memset(conn, 0, sizeof(*conn));
	conn->out.event_id = -1;
	conn->in.event_id  = -1;

	conn->out.buf = malloc(bufsz);
	if (!conn->out.buf) {
		err = -ENOMEM;
		goto fail;
	}
	conn->out.bufsz = page_align(bufsz);

	return 0;

fail:
	tapdisk_ctl_conn_uninit(conn);
	return err;
}