Lines Matching full:file

6  * General Public License (GPL) Version 2, available from the file
34 #include <linux/file.h>
80 struct file *filp;
93 struct ucma_file *file;
129 struct ucma_file *file)
136 else if (ctx->file != file)
141 static struct ucma_context *ucma_get_ctx(struct ucma_file *file, int id)
146 ctx = _ucma_find_context(id, file);
164 static struct ucma_context *ucma_get_ctx_dev(struct ucma_file *file, int id)
166 struct ucma_context *ctx = ucma_get_ctx(file, id);
194 static struct ucma_context *ucma_alloc_ctx(struct ucma_file *file)
207 ctx->file = file;
226 lockdep_assert_held(&ctx->file->mut);
227 list_add_tail(&ctx->list, &ctx->file->ctx_list);
306 ctx = ucma_alloc_ctx(listen_ctx->file);
319 mutex_lock(&ctx->file->mut);
321 list_add_tail(&uevent->list, &ctx->file->event_list);
322 mutex_unlock(&ctx->file->mut);
323 wake_up_interruptible(&ctx->file->poll_wait);
355 mutex_lock(&ctx->file->mut);
356 list_add_tail(&uevent->list, &ctx->file->event_list);
357 mutex_unlock(&ctx->file->mut);
358 wake_up_interruptible(&ctx->file->poll_wait);
370 static ssize_t ucma_get_event(struct ucma_file *file, const char __user *inbuf,
387 mutex_lock(&file->mut);
388 while (list_empty(&file->event_list)) {
389 mutex_unlock(&file->mut);
391 if (file->filp->f_flags & O_NONBLOCK)
394 if (wait_event_interruptible(file->poll_wait,
395 !list_empty(&file->event_list)))
398 mutex_lock(&file->mut);
401 uevent = list_first_entry(&file->event_list, struct ucma_event, list);
406 mutex_unlock(&file->mut);
416 mutex_unlock(&file->mut);
440 static ssize_t ucma_create_id(struct ucma_file *file, const char __user *inbuf,
460 ctx = ucma_alloc_ctx(file);
479 mutex_lock(&file->mut);
481 mutex_unlock(&file->mut);
511 mutex_lock(&mc->ctx->file->mut);
512 list_for_each_entry_safe(uevent, tmp, &mc->ctx->file->event_list, list) {
519 mutex_unlock(&mc->ctx->file->mut);
530 mutex_lock(&ctx->file->mut);
531 list_for_each_entry_safe(uevent, tmp, &ctx->file->event_list, list) {
547 mutex_unlock(&ctx->file->mut);
592 static ssize_t ucma_destroy_id(struct ucma_file *file, const char __user *inbuf,
607 ctx = _ucma_find_context(cmd.id, file);
626 static ssize_t ucma_bind_ip(struct ucma_file *file, const char __user *inbuf,
639 ctx = ucma_get_ctx(file, cmd.id);
651 static ssize_t ucma_bind(struct ucma_file *file, const char __user *inbuf,
665 ctx = ucma_get_ctx(file, cmd.id);
676 static ssize_t ucma_resolve_ip(struct ucma_file *file,
691 ctx = ucma_get_ctx(file, cmd.id);
703 static ssize_t ucma_resolve_addr(struct ucma_file *file,
719 ctx = ucma_get_ctx(file, cmd.id);
731 static ssize_t ucma_resolve_route(struct ucma_file *file,
742 ctx = ucma_get_ctx_dev(file, cmd.id);
817 static ssize_t ucma_query_route(struct ucma_file *file,
833 ctx = ucma_get_ctx(file, cmd.id);
997 static ssize_t ucma_query(struct ucma_file *file,
1010 ctx = ucma_get_ctx(file, cmd.id);
1051 static ssize_t ucma_connect(struct ucma_file *file, const char __user *inbuf,
1070 ctx = ucma_get_ctx_dev(file, cmd.id);
1087 static ssize_t ucma_listen(struct ucma_file *file, const char __user *inbuf,
1097 ctx = ucma_get_ctx(file, cmd.id);
1112 static ssize_t ucma_accept(struct ucma_file *file, const char __user *inbuf,
1128 ctx = ucma_get_ctx_dev(file, cmd.id);
1159 static ssize_t ucma_reject(struct ucma_file *file, const char __user *inbuf,
1180 ctx = ucma_get_ctx_dev(file, cmd.id);
1192 static ssize_t ucma_disconnect(struct ucma_file *file, const char __user *inbuf,
1202 ctx = ucma_get_ctx_dev(file, cmd.id);
1213 static ssize_t ucma_init_qp_attr(struct ucma_file *file,
1232 ctx = ucma_get_ctx_dev(file, cmd.id);
1380 static ssize_t ucma_set_option(struct ucma_file *file, const char __user *inbuf,
1394 ctx = ucma_get_ctx(file, cmd.id);
1414 static ssize_t ucma_notify(struct ucma_file *file, const char __user *inbuf,
1424 ctx = ucma_get_ctx(file, cmd.id);
1437 static ssize_t ucma_process_join(struct ucma_file *file,
1461 ctx = ucma_get_ctx_dev(file, cmd->id);
1522 static ssize_t ucma_join_ip_multicast(struct ucma_file *file,
1542 return ucma_process_join(file, &join_cmd, out_len);
1545 static ssize_t ucma_join_multicast(struct ucma_file *file,
1557 return ucma_process_join(file, &cmd, out_len);
1560 static ssize_t ucma_leave_multicast(struct ucma_file *file,
1579 else if (READ_ONCE(mc->ctx->file) != file)
1641 * ctx->file can only be changed under the handler & xa_lock. xa_load()
1651 ctx->file = new_file;
1681 static ssize_t (*ucma_cmd_table[])(struct ucma_file *file,
1709 static ssize_t ucma_write(struct file *filp, const char __user *buf,
1712 struct ucma_file *file = filp->private_data;
1717 pr_err_once("%s: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n",
1738 ret = ucma_cmd_table[hdr.cmd](file, buf + sizeof(hdr), hdr.in, hdr.out);
1745 static __poll_t ucma_poll(struct file *filp, struct poll_table_struct *wait)
1747 struct ucma_file *file = filp->private_data;
1750 poll_wait(filp, &file->poll_wait, wait);
1752 if (!list_empty(&file->event_list))
1766 static int ucma_open(struct inode *inode, struct file *filp)
1768 struct ucma_file *file;
1770 file = kmalloc(sizeof *file, GFP_KERNEL);
1771 if (!file)
1774 INIT_LIST_HEAD(&file->event_list);
1775 INIT_LIST_HEAD(&file->ctx_list);
1776 init_waitqueue_head(&file->poll_wait);
1777 mutex_init(&file->mut);
1779 filp->private_data = file;
1780 file->filp = filp;
1785 static int ucma_close(struct inode *inode, struct file *filp)
1787 struct ucma_file *file = filp->private_data;
1797 while (!list_empty(&file->ctx_list)) {
1799 &file->ctx_list, struct ucma_context, list);
1805 kfree(file);