Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
kernel_linux
提交
e4fad8e5
K
kernel_linux
项目概览
OpenHarmony
/
kernel_linux
上一次同步 4 年多
通知
15
Star
8
Fork
2
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kernel_linux
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e4fad8e5
编写于
7月 21, 2012
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
consolidate pipe file creation
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
b5bcdda3
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
34 addition
and
65 deletion
+34
-65
fs/exec.c
fs/exec.c
+6
-13
fs/pipe.c
fs/pipe.c
+26
-49
include/linux/fs.h
include/linux/fs.h
+0
-3
include/linux/pipe_fs_i.h
include/linux/pipe_fs_i.h
+2
-0
未找到文件。
fs/exec.c
浏览文件 @
e4fad8e5
...
@@ -2069,25 +2069,18 @@ static void wait_for_dump_helpers(struct file *file)
...
@@ -2069,25 +2069,18 @@ static void wait_for_dump_helpers(struct file *file)
*/
*/
static
int
umh_pipe_setup
(
struct
subprocess_info
*
info
,
struct
cred
*
new
)
static
int
umh_pipe_setup
(
struct
subprocess_info
*
info
,
struct
cred
*
new
)
{
{
struct
file
*
rp
,
*
wp
;
struct
file
*
files
[
2
]
;
struct
fdtable
*
fdt
;
struct
fdtable
*
fdt
;
struct
coredump_params
*
cp
=
(
struct
coredump_params
*
)
info
->
data
;
struct
coredump_params
*
cp
=
(
struct
coredump_params
*
)
info
->
data
;
struct
files_struct
*
cf
=
current
->
files
;
struct
files_struct
*
cf
=
current
->
files
;
int
err
=
create_pipe_files
(
files
,
0
);
if
(
err
)
return
err
;
wp
=
create_write_pipe
(
0
);
cp
->
file
=
files
[
1
];
if
(
IS_ERR
(
wp
))
return
PTR_ERR
(
wp
);
rp
=
create_read_pipe
(
wp
,
0
);
if
(
IS_ERR
(
rp
))
{
free_write_pipe
(
wp
);
return
PTR_ERR
(
rp
);
}
cp
->
file
=
wp
;
sys_close
(
0
);
sys_close
(
0
);
fd_install
(
0
,
rp
);
fd_install
(
0
,
files
[
0
]
);
spin_lock
(
&
cf
->
file_lock
);
spin_lock
(
&
cf
->
file_lock
);
fdt
=
files_fdtable
(
cf
);
fdt
=
files_fdtable
(
cf
);
__set_open_fd
(
0
,
fdt
);
__set_open_fd
(
0
,
fdt
);
...
...
fs/pipe.c
浏览文件 @
e4fad8e5
...
@@ -1016,18 +1016,16 @@ static struct inode * get_pipe_inode(void)
...
@@ -1016,18 +1016,16 @@ static struct inode * get_pipe_inode(void)
return
NULL
;
return
NULL
;
}
}
struct
file
*
create_write_pipe
(
int
flags
)
int
create_pipe_files
(
struct
file
**
res
,
int
flags
)
{
{
int
err
;
int
err
;
struct
inode
*
inode
;
struct
inode
*
inode
=
get_pipe_inode
()
;
struct
file
*
f
;
struct
file
*
f
;
struct
path
path
;
struct
path
path
;
struct
qstr
name
=
{
.
name
=
""
};
st
atic
st
ruct
qstr
name
=
{
.
name
=
""
};
err
=
-
ENFILE
;
inode
=
get_pipe_inode
();
if
(
!
inode
)
if
(
!
inode
)
goto
err
;
return
-
ENFILE
;
err
=
-
ENOMEM
;
err
=
-
ENOMEM
;
path
.
dentry
=
d_alloc_pseudo
(
pipe_mnt
->
mnt_sb
,
&
name
);
path
.
dentry
=
d_alloc_pseudo
(
pipe_mnt
->
mnt_sb
,
&
name
);
...
@@ -1041,62 +1039,43 @@ struct file *create_write_pipe(int flags)
...
@@ -1041,62 +1039,43 @@ struct file *create_write_pipe(int flags)
f
=
alloc_file
(
&
path
,
FMODE_WRITE
,
&
write_pipefifo_fops
);
f
=
alloc_file
(
&
path
,
FMODE_WRITE
,
&
write_pipefifo_fops
);
if
(
!
f
)
if
(
!
f
)
goto
err_dentry
;
goto
err_dentry
;
f
->
f_mapping
=
inode
->
i_mapping
;
f
->
f_flags
=
O_WRONLY
|
(
flags
&
(
O_NONBLOCK
|
O_DIRECT
));
f
->
f_flags
=
O_WRONLY
|
(
flags
&
(
O_NONBLOCK
|
O_DIRECT
));
f
->
f_version
=
0
;
return
f
;
res
[
0
]
=
alloc_file
(
&
path
,
FMODE_READ
,
&
read_pipefifo_fops
);
if
(
!
res
[
0
])
goto
err_file
;
path_get
(
&
path
);
res
[
0
]
->
f_flags
=
O_RDONLY
|
(
flags
&
O_NONBLOCK
);
res
[
1
]
=
f
;
return
0
;
err_dentry:
err_file:
put_filp
(
f
);
err_dentry:
free_pipe_info
(
inode
);
free_pipe_info
(
inode
);
path_put
(
&
path
);
path_put
(
&
path
);
return
ERR_PTR
(
err
)
;
return
err
;
err_inode:
err_inode:
free_pipe_info
(
inode
);
free_pipe_info
(
inode
);
iput
(
inode
);
iput
(
inode
);
err:
return
err
;
return
ERR_PTR
(
err
);
}
void
free_write_pipe
(
struct
file
*
f
)
{
free_pipe_info
(
f
->
f_dentry
->
d_inode
);
path_put
(
&
f
->
f_path
);
put_filp
(
f
);
}
struct
file
*
create_read_pipe
(
struct
file
*
wrf
,
int
flags
)
{
/* Grab pipe from the writer */
struct
file
*
f
=
alloc_file
(
&
wrf
->
f_path
,
FMODE_READ
,
&
read_pipefifo_fops
);
if
(
!
f
)
return
ERR_PTR
(
-
ENFILE
);
path_get
(
&
wrf
->
f_path
);
f
->
f_flags
=
O_RDONLY
|
(
flags
&
O_NONBLOCK
);
return
f
;
}
}
int
do_pipe_flags
(
int
*
fd
,
int
flags
)
int
do_pipe_flags
(
int
*
fd
,
int
flags
)
{
{
struct
file
*
f
w
,
*
fr
;
struct
file
*
f
iles
[
2
]
;
int
error
;
int
error
;
int
fdw
,
fdr
;
int
fdw
,
fdr
;
if
(
flags
&
~
(
O_CLOEXEC
|
O_NONBLOCK
|
O_DIRECT
))
if
(
flags
&
~
(
O_CLOEXEC
|
O_NONBLOCK
|
O_DIRECT
))
return
-
EINVAL
;
return
-
EINVAL
;
fw
=
create_write_pipe
(
flags
);
error
=
create_pipe_files
(
files
,
flags
);
if
(
IS_ERR
(
fw
))
if
(
error
)
return
PTR_ERR
(
fw
);
return
error
;
fr
=
create_read_pipe
(
fw
,
flags
);
error
=
PTR_ERR
(
fr
);
if
(
IS_ERR
(
fr
))
goto
err_write_pipe
;
error
=
get_unused_fd_flags
(
flags
);
error
=
get_unused_fd_flags
(
flags
);
if
(
error
<
0
)
if
(
error
<
0
)
...
@@ -1109,8 +1088,8 @@ int do_pipe_flags(int *fd, int flags)
...
@@ -1109,8 +1088,8 @@ int do_pipe_flags(int *fd, int flags)
fdw
=
error
;
fdw
=
error
;
audit_fd_pair
(
fdr
,
fdw
);
audit_fd_pair
(
fdr
,
fdw
);
fd_install
(
fdr
,
f
r
);
fd_install
(
fdr
,
f
iles
[
0
]
);
fd_install
(
fdw
,
f
w
);
fd_install
(
fdw
,
f
iles
[
1
]
);
fd
[
0
]
=
fdr
;
fd
[
0
]
=
fdr
;
fd
[
1
]
=
fdw
;
fd
[
1
]
=
fdw
;
...
@@ -1119,10 +1098,8 @@ int do_pipe_flags(int *fd, int flags)
...
@@ -1119,10 +1098,8 @@ int do_pipe_flags(int *fd, int flags)
err_fdr:
err_fdr:
put_unused_fd
(
fdr
);
put_unused_fd
(
fdr
);
err_read_pipe:
err_read_pipe:
path_put
(
&
fr
->
f_path
);
fput
(
files
[
0
]);
put_filp
(
fr
);
fput
(
files
[
1
]);
err_write_pipe:
free_write_pipe
(
fw
);
return
error
;
return
error
;
}
}
...
...
include/linux/fs.h
浏览文件 @
e4fad8e5
...
@@ -2326,9 +2326,6 @@ static inline void i_readcount_inc(struct inode *inode)
...
@@ -2326,9 +2326,6 @@ static inline void i_readcount_inc(struct inode *inode)
}
}
#endif
#endif
extern
int
do_pipe_flags
(
int
*
,
int
);
extern
int
do_pipe_flags
(
int
*
,
int
);
extern
struct
file
*
create_read_pipe
(
struct
file
*
f
,
int
flags
);
extern
struct
file
*
create_write_pipe
(
int
flags
);
extern
void
free_write_pipe
(
struct
file
*
);
extern
int
kernel_read
(
struct
file
*
,
loff_t
,
char
*
,
unsigned
long
);
extern
int
kernel_read
(
struct
file
*
,
loff_t
,
char
*
,
unsigned
long
);
extern
struct
file
*
open_exec
(
const
char
*
);
extern
struct
file
*
open_exec
(
const
char
*
);
...
...
include/linux/pipe_fs_i.h
浏览文件 @
e4fad8e5
...
@@ -162,4 +162,6 @@ void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
...
@@ -162,4 +162,6 @@ void generic_pipe_buf_release(struct pipe_inode_info *, struct pipe_buffer *);
long
pipe_fcntl
(
struct
file
*
,
unsigned
int
,
unsigned
long
arg
);
long
pipe_fcntl
(
struct
file
*
,
unsigned
int
,
unsigned
long
arg
);
struct
pipe_inode_info
*
get_pipe_info
(
struct
file
*
file
);
struct
pipe_inode_info
*
get_pipe_info
(
struct
file
*
file
);
int
create_pipe_files
(
struct
file
**
,
int
);
#endif
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录