Lines Matching defs:file

59 #include <linux/file.h>
120 static int sock_mmap(struct file *file, struct vm_area_struct *vma);
122 static int sock_close(struct inode *inode, struct file *file);
123 static __poll_t sock_poll(struct file *file,
125 static long sock_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
127 static long compat_sock_ioctl(struct file *file,
130 static int sock_fasync(int fd, struct file *filp, int on);
131 static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
134 static void sock_splice_eof(struct file *file);
137 static void sock_show_fdinfo(struct seq_file *m, struct file *f)
150 * Socket files have a set of 'special' operations as well as the generic file ones. These don't appear
319 ei->socket.file = NULL;
432 * Obtains the first available file descriptor and sets it up for use.
434 * These functions create file structures and maps them to fd space
435 * of the current process. On success it returns file descriptor
436 * and file struct implicitly stored in sock->file.
437 * Note that another thread may close file descriptor before we return
440 * function will increment ref. count on file by 1.
449 * sock_alloc_file - Bind a &socket to a &file
451 * @flags: file status flags
454 * Returns the &file bound with @sock, implicitly storing it
455 * in sock->file. If dname is %NULL, sets to "".
462 struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname)
464 struct file *file;
469 file = alloc_file_pseudo(SOCK_INODE(sock), sock_mnt, dname,
472 if (IS_ERR(file)) {
474 return file;
477 file->f_mode |= FMODE_NOWAIT;
478 sock->file = file;
479 file->private_data = sock;
480 stream_open(SOCK_INODE(sock), file);
481 return file;
487 struct file *newfile;
505 * sock_from_file - Return the &socket bounded to @file.
506 * @file: file
511 struct socket *sock_from_file(struct file *file)
513 if (file->f_op == &socket_file_ops)
514 return file->private_data; /* set in sock_alloc_file */
521 * sockfd_lookup - Go from a file number to its socket slot
522 * @fd: file handle
525 * The file handle passed in is locked and the socket it is bound
535 struct file *file;
538 file = fget(fd);
539 if (!file) {
544 sock = sock_from_file(file);
547 fput(file);
559 if (f.file) {
560 sock = sock_from_file(f.file);
670 if (!sock->file) {
674 sock->file = NULL;
683 * an inode not a file.
1097 static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
1101 struct socket *sock = file->private_data;
1106 return copy_splice_read(file, ppos, pipe, len, flags);
1111 static void sock_splice_eof(struct file *file)
1113 struct socket *sock = file->private_data;
1123 struct file *file = iocb->ki_filp;
1124 struct socket *sock = file->private_data;
1129 if (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT))
1145 struct file *file = iocb->ki_filp;
1146 struct socket *sock = file->private_data;
1154 if (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT))
1249 static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg)
1258 sock = file->private_data;
1284 err = f_setown(sock->file, pid, 1);
1288 err = put_user(f_getown(sock->file),
1391 static __poll_t sock_poll(struct file *file, poll_table *wait)
1393 struct socket *sock = file->private_data;
1409 return ops->poll(file, sock, wait) | flag;
1412 static int sock_mmap(struct file *file, struct vm_area_struct *vma)
1414 struct socket *sock = file->private_data;
1416 return READ_ONCE(sock->ops)->mmap(file, sock, vma);
1419 static int sock_close(struct inode *inode, struct file *filp)
1436 static int sock_fasync(int fd, struct file *filp, int on)
1666 struct file *__sys_socket_file(int family, int type, int protocol)
1731 struct file *newfile1, *newfile2;
1851 fput_light(sock->file, fput_needed);
1883 fput_light(sock->file, fput_needed);
1893 struct file *do_accept(struct file *file, unsigned file_flags,
1898 struct file *newfile;
1903 sock = sock_from_file(file);
1929 err = ops->accept(sock, newsock, sock->file->f_flags | file_flags,
1953 static int __sys_accept4_file(struct file *file, struct sockaddr __user *upeer_sockaddr,
1956 struct file *newfile;
1969 newfile = do_accept(file, 0, upeer_sockaddr, upeer_addrlen,
1998 if (f.file) {
1999 ret = __sys_accept4_file(f.file, upeer_sockaddr,
2031 int __sys_connect_file(struct file *file, struct sockaddr_storage *address,
2037 sock = sock_from_file(file);
2049 addrlen, sock->file->f_flags | file_flags);
2060 if (f.file) {
2065 ret = __sys_connect_file(f.file, &address, addrlen, 0);
2105 fput_light(sock->file, fput_needed);
2134 fput_light(sock->file, fput_needed);
2143 fput_light(sock->file, fput_needed);
2188 if (sock->file->f_flags & O_NONBLOCK)
2194 fput_light(sock->file, fput_needed);
2240 if (sock->file->f_flags & O_NONBLOCK)
2251 fput_light(sock->file, fput_needed);
2336 fput_light(sock->file, fput_needed);
2405 fput_light(sock->file, fput_needed);
2438 fput_light(sock->file, fput_needed);
2569 if (sock->file->f_flags & O_NONBLOCK)
2669 fput_light(sock->file, fput_needed);
2741 fput_light(sock->file, fput_needed);
2797 if (sock->file->f_flags & O_NONBLOCK)
2877 fput_light(sock->file, fput_needed);
2998 fput_light(sock->file, fput_needed);
3411 static int compat_sock_ioctl_trans(struct file *file, struct socket *sock,
3420 return sock_ioctl(file, cmd, (unsigned long)argp);
3454 return sock_ioctl(file, cmd, arg);
3508 static long compat_sock_ioctl(struct file *file, unsigned int cmd,
3511 struct socket *sock = file->private_data;
3528 ret = compat_sock_ioctl_trans(file, sock, cmd, arg);