0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef SPLICE_H
0010 #define SPLICE_H
0011
0012 #include <linux/pipe_fs_i.h>
0013
0014
0015
0016
0017 #define SPLICE_F_MOVE (0x01)
0018 #define SPLICE_F_NONBLOCK (0x02)
0019
0020
0021 #define SPLICE_F_MORE (0x04)
0022 #define SPLICE_F_GIFT (0x08)
0023
0024 #define SPLICE_F_ALL (SPLICE_F_MOVE|SPLICE_F_NONBLOCK|SPLICE_F_MORE|SPLICE_F_GIFT)
0025
0026
0027
0028
0029 struct splice_desc {
0030 size_t total_len;
0031 unsigned int len;
0032 unsigned int flags;
0033
0034
0035
0036 union {
0037 void __user *userptr;
0038 struct file *file;
0039 void *data;
0040 } u;
0041 loff_t pos;
0042 loff_t *opos;
0043 size_t num_spliced;
0044 bool need_wakeup;
0045 };
0046
0047 struct partial_page {
0048 unsigned int offset;
0049 unsigned int len;
0050 unsigned long private;
0051 };
0052
0053
0054
0055
0056 struct splice_pipe_desc {
0057 struct page **pages;
0058 struct partial_page *partial;
0059 int nr_pages;
0060 unsigned int nr_pages_max;
0061 const struct pipe_buf_operations *ops;
0062 void (*spd_release)(struct splice_pipe_desc *, unsigned int);
0063 };
0064
0065 typedef int (splice_actor)(struct pipe_inode_info *, struct pipe_buffer *,
0066 struct splice_desc *);
0067 typedef int (splice_direct_actor)(struct pipe_inode_info *,
0068 struct splice_desc *);
0069
0070 extern ssize_t splice_from_pipe(struct pipe_inode_info *, struct file *,
0071 loff_t *, size_t, unsigned int,
0072 splice_actor *);
0073 extern ssize_t __splice_from_pipe(struct pipe_inode_info *,
0074 struct splice_desc *, splice_actor *);
0075 extern ssize_t splice_to_pipe(struct pipe_inode_info *,
0076 struct splice_pipe_desc *);
0077 extern ssize_t add_to_pipe(struct pipe_inode_info *,
0078 struct pipe_buffer *);
0079 extern ssize_t splice_direct_to_actor(struct file *, struct splice_desc *,
0080 splice_direct_actor *);
0081 extern long do_splice(struct file *in, loff_t *off_in,
0082 struct file *out, loff_t *off_out,
0083 size_t len, unsigned int flags);
0084
0085 extern long do_tee(struct file *in, struct file *out, size_t len,
0086 unsigned int flags);
0087
0088
0089
0090
0091 extern int splice_grow_spd(const struct pipe_inode_info *, struct splice_pipe_desc *);
0092 extern void splice_shrink_spd(struct splice_pipe_desc *);
0093
0094 extern const struct pipe_buf_operations page_cache_pipe_buf_ops;
0095 extern const struct pipe_buf_operations default_pipe_buf_ops;
0096 #endif