Exemplo n.º 1
0
/*
 * upon a create, we allocate an empty protocol data, and grab a page to
 * buffer writes
 */
static int
unix_proto_create(struct socket *sock, int protocol)
{
	struct unix_proto_data *upd;

	PRINTK("unix_proto_create: socket 0x%x, proto %d\n", sock, protocol);
	if (protocol != 0) {
		PRINTK("unix_proto_create: protocol != 0\n");
		return -EINVAL;
	}
	if (!(upd = unix_data_alloc())) {
		printk("unix_proto_create: can't allocate buffer\n");
		return -ENOMEM;
	}
	if (!(upd->buf = (char *)get_free_page())) {
		printk("unix_proto_create: can't get page!\n");
		unix_data_deref(upd);
		return -ENOMEM;
	}
	upd->protocol = protocol;
	upd->socket = sock;
	UN_DATA(sock) = upd;
	PRINTK("unix_proto_create: allocated data 0x%x\n", upd);
	return 0;
}
Exemplo n.º 2
0
static int unix_create(struct socket *sock, int protocol)
{
    struct unix_proto_data *upd;

    if (protocol != 0)
	return -EINVAL;

    if (!(upd = unix_data_alloc()))
	return -ENOMEM;

#if 0
    upd->protocol = protocol;	/* I don't think this is necessary */
#endif

    upd->socket = sock;
    sock->data = upd;
    upd->refcnt = 1;

    return 0;
}