static int unix_proto_release(struct socket *sock, struct socket *peer) { struct unix_proto_data *upd = UN_DATA(sock); PRINTK("unix_proto_release: socket 0x%x, unix_data 0x%x\n", sock, upd); if (!upd) return 0; if (upd->socket != sock) { printk("unix_proto_release: socket link mismatch!\n"); return -EINVAL; } if (upd->inode) { PRINTK("unix_proto_release: releasing inode 0x%x\n", upd->inode); iput(upd->inode); upd->inode = NULL; } UN_DATA(sock) = NULL; upd->socket = NULL; if (upd->peerupd) unix_data_deref(upd->peerupd); unix_data_deref(upd); return 0; }
static int unix_release(struct socket *sock, struct socket *peer) { struct unix_proto_data *upd = sock->data; if (!upd) return 0; if (upd->socket != sock) { printk("UNIX: release: socket link mismatch!\n"); return -EINVAL; } if (upd->inode) { iput(upd->inode); upd->inode = NULL; } sock->data = NULL; upd->socket = NULL; if (upd->peerupd) unix_data_deref(upd->peerupd); unix_data_deref(upd); return 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; }