mirror of
https://github.com/tbsdtv/linux_media.git
synced 2025-07-23 12:43:29 +02:00
take the guts of file-to-pipe splice into a helper function
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
25
fs/splice.c
25
fs/splice.c
@@ -1002,6 +1002,23 @@ static int splice_pipe_to_pipe(struct pipe_inode_info *ipipe,
|
|||||||
struct pipe_inode_info *opipe,
|
struct pipe_inode_info *opipe,
|
||||||
size_t len, unsigned int flags);
|
size_t len, unsigned int flags);
|
||||||
|
|
||||||
|
static long splice_file_to_pipe(struct file *in,
|
||||||
|
struct pipe_inode_info *opipe,
|
||||||
|
loff_t *offset,
|
||||||
|
size_t len, unsigned int flags)
|
||||||
|
{
|
||||||
|
long ret;
|
||||||
|
|
||||||
|
pipe_lock(opipe);
|
||||||
|
ret = wait_for_space(opipe, flags);
|
||||||
|
if (!ret)
|
||||||
|
ret = do_splice_to(in, offset, opipe, len, flags);
|
||||||
|
pipe_unlock(opipe);
|
||||||
|
if (ret > 0)
|
||||||
|
wakeup_pipe_readers(opipe);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Determine where to splice to/from.
|
* Determine where to splice to/from.
|
||||||
*/
|
*/
|
||||||
@@ -1081,13 +1098,7 @@ long do_splice(struct file *in, loff_t *off_in, struct file *out,
|
|||||||
if (out->f_flags & O_NONBLOCK)
|
if (out->f_flags & O_NONBLOCK)
|
||||||
flags |= SPLICE_F_NONBLOCK;
|
flags |= SPLICE_F_NONBLOCK;
|
||||||
|
|
||||||
pipe_lock(opipe);
|
ret = splice_file_to_pipe(in, opipe, &offset, len, flags);
|
||||||
ret = wait_for_space(opipe, flags);
|
|
||||||
if (!ret)
|
|
||||||
ret = do_splice_to(in, &offset, opipe, len, flags);
|
|
||||||
pipe_unlock(opipe);
|
|
||||||
if (ret > 0)
|
|
||||||
wakeup_pipe_readers(opipe);
|
|
||||||
if (!off_in)
|
if (!off_in)
|
||||||
in->f_pos = offset;
|
in->f_pos = offset;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user