mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-03-30 10:55:03 +00:00
new helper: alloc_file_clone()
alloc_file_clone(old_file, mode, ops): create a new struct file with ->f_path equal to that of old_file. pipe converted. Acked-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
152b6372c9
commit
183266f26f
3 changed files with 15 additions and 4 deletions
|
@ -211,6 +211,17 @@ struct file *alloc_file_pseudo(struct inode *inode, struct vfsmount *mnt,
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL(alloc_file_pseudo);
|
EXPORT_SYMBOL(alloc_file_pseudo);
|
||||||
|
|
||||||
|
struct file *alloc_file_clone(struct file *base, int flags,
|
||||||
|
const struct file_operations *fops)
|
||||||
|
{
|
||||||
|
struct file *f = alloc_file(&base->f_path, flags, fops);
|
||||||
|
if (!IS_ERR(f)) {
|
||||||
|
path_get(&f->f_path);
|
||||||
|
f->f_mapping = base->f_mapping;
|
||||||
|
}
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
/* the real guts of fput() - releasing the last reference to file
|
/* the real guts of fput() - releasing the last reference to file
|
||||||
*/
|
*/
|
||||||
static void __fput(struct file *file)
|
static void __fput(struct file *file)
|
||||||
|
|
|
@ -761,15 +761,13 @@ int create_pipe_files(struct file **res, int flags)
|
||||||
|
|
||||||
f->private_data = inode->i_pipe;
|
f->private_data = inode->i_pipe;
|
||||||
|
|
||||||
res[0] = alloc_file(&f->f_path, O_RDONLY | (flags & O_NONBLOCK),
|
res[0] = alloc_file_clone(f, O_RDONLY | (flags & O_NONBLOCK),
|
||||||
&pipefifo_fops);
|
&pipefifo_fops);
|
||||||
if (IS_ERR(res[0])) {
|
if (IS_ERR(res[0])) {
|
||||||
put_pipe_info(inode, inode->i_pipe);
|
put_pipe_info(inode, inode->i_pipe);
|
||||||
fput(f);
|
fput(f);
|
||||||
return PTR_ERR(res[0]);
|
return PTR_ERR(res[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
path_get(&f->f_path);
|
|
||||||
res[0]->private_data = inode->i_pipe;
|
res[0]->private_data = inode->i_pipe;
|
||||||
res[1] = f;
|
res[1] = f;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -23,6 +23,8 @@ extern struct file *alloc_file(const struct path *, int flags,
|
||||||
const struct file_operations *fop);
|
const struct file_operations *fop);
|
||||||
extern struct file *alloc_file_pseudo(struct inode *, struct vfsmount *,
|
extern struct file *alloc_file_pseudo(struct inode *, struct vfsmount *,
|
||||||
const char *, int flags, const struct file_operations *);
|
const char *, int flags, const struct file_operations *);
|
||||||
|
extern struct file *alloc_file_clone(struct file *, int flags,
|
||||||
|
const struct file_operations *);
|
||||||
|
|
||||||
static inline void fput_light(struct file *file, int fput_needed)
|
static inline void fput_light(struct file *file, int fput_needed)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue