Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
Kernel
提交
f776c738
K
Kernel
项目概览
openeuler
/
Kernel
接近 2 年 前同步成功
通知
8
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
f776c738
编写于
3月 12, 2013
作者:
A
Al Viro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fold fifo.c into pipe.c
Signed-off-by:
N
Al Viro
<
viro@zeniv.linux.org.uk
>
上级
2dd8c9ad
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
139 addition
and
154 deletion
+139
-154
fs/Makefile
fs/Makefile
+1
-1
fs/fifo.c
fs/fifo.c
+0
-153
fs/pipe.c
fs/pipe.c
+138
-0
未找到文件。
fs/Makefile
浏览文件 @
f776c738
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
obj-y
:=
open.o read_write.o file_table.o super.o
\
obj-y
:=
open.o read_write.o file_table.o super.o
\
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o
\
char_dev.o stat.o exec.o pipe.o namei.o fcntl.o
\
ioctl.o readdir.o
select
.o
fifo.o
dcache.o inode.o
\
ioctl.o readdir.o
select
.o dcache.o inode.o
\
attr.o bad_inode.o file.o filesystems.o namespace.o
\
attr.o bad_inode.o file.o filesystems.o namespace.o
\
seq_file.o xattr.o libfs.o fs-writeback.o
\
seq_file.o xattr.o libfs.o fs-writeback.o
\
pnode.o drop_caches.o splice.o sync.o utimes.o
\
pnode.o drop_caches.o splice.o sync.o utimes.o
\
...
...
fs/fifo.c
已删除
100644 → 0
浏览文件 @
2dd8c9ad
/*
* linux/fs/fifo.c
*
* written by Paul H. Hargrove
*
* Fixes:
* 10-06-1999, AV: fixed OOM handling in fifo_open(), moved
* initialization there, switched to external
* allocation of pipe_inode_info.
*/
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/pipe_fs_i.h>
static
int
wait_for_partner
(
struct
inode
*
inode
,
unsigned
int
*
cnt
)
{
int
cur
=
*
cnt
;
while
(
cur
==
*
cnt
)
{
pipe_wait
(
inode
->
i_pipe
);
if
(
signal_pending
(
current
))
break
;
}
return
cur
==
*
cnt
?
-
ERESTARTSYS
:
0
;
}
static
void
wake_up_partner
(
struct
inode
*
inode
)
{
wake_up_interruptible
(
&
inode
->
i_pipe
->
wait
);
}
static
int
fifo_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
struct
pipe_inode_info
*
pipe
;
int
ret
;
mutex_lock
(
&
inode
->
i_mutex
);
pipe
=
inode
->
i_pipe
;
if
(
!
pipe
)
{
ret
=
-
ENOMEM
;
pipe
=
alloc_pipe_info
(
inode
);
if
(
!
pipe
)
goto
err_nocleanup
;
inode
->
i_pipe
=
pipe
;
}
filp
->
f_version
=
0
;
/* We can only do regular read/write on fifos */
filp
->
f_mode
&=
(
FMODE_READ
|
FMODE_WRITE
);
switch
(
filp
->
f_mode
)
{
case
FMODE_READ
:
/*
* O_RDONLY
* POSIX.1 says that O_NONBLOCK means return with the FIFO
* opened, even when there is no process writing the FIFO.
*/
filp
->
f_op
=
&
read_pipefifo_fops
;
pipe
->
r_counter
++
;
if
(
pipe
->
readers
++
==
0
)
wake_up_partner
(
inode
);
if
(
!
pipe
->
writers
)
{
if
((
filp
->
f_flags
&
O_NONBLOCK
))
{
/* suppress POLLHUP until we have
* seen a writer */
filp
->
f_version
=
pipe
->
w_counter
;
}
else
{
if
(
wait_for_partner
(
inode
,
&
pipe
->
w_counter
))
goto
err_rd
;
}
}
break
;
case
FMODE_WRITE
:
/*
* O_WRONLY
* POSIX.1 says that O_NONBLOCK means return -1 with
* errno=ENXIO when there is no process reading the FIFO.
*/
ret
=
-
ENXIO
;
if
((
filp
->
f_flags
&
O_NONBLOCK
)
&&
!
pipe
->
readers
)
goto
err
;
filp
->
f_op
=
&
write_pipefifo_fops
;
pipe
->
w_counter
++
;
if
(
!
pipe
->
writers
++
)
wake_up_partner
(
inode
);
if
(
!
pipe
->
readers
)
{
if
(
wait_for_partner
(
inode
,
&
pipe
->
r_counter
))
goto
err_wr
;
}
break
;
case
FMODE_READ
|
FMODE_WRITE
:
/*
* O_RDWR
* POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
* This implementation will NEVER block on a O_RDWR open, since
* the process can at least talk to itself.
*/
filp
->
f_op
=
&
rdwr_pipefifo_fops
;
pipe
->
readers
++
;
pipe
->
writers
++
;
pipe
->
r_counter
++
;
pipe
->
w_counter
++
;
if
(
pipe
->
readers
==
1
||
pipe
->
writers
==
1
)
wake_up_partner
(
inode
);
break
;
default:
ret
=
-
EINVAL
;
goto
err
;
}
/* Ok! */
mutex_unlock
(
&
inode
->
i_mutex
);
return
0
;
err_rd:
if
(
!--
pipe
->
readers
)
wake_up_interruptible
(
&
pipe
->
wait
);
ret
=
-
ERESTARTSYS
;
goto
err
;
err_wr:
if
(
!--
pipe
->
writers
)
wake_up_interruptible
(
&
pipe
->
wait
);
ret
=
-
ERESTARTSYS
;
goto
err
;
err:
if
(
!
pipe
->
readers
&&
!
pipe
->
writers
)
free_pipe_info
(
inode
);
err_nocleanup:
mutex_unlock
(
&
inode
->
i_mutex
);
return
ret
;
}
/*
* Dummy default file-operations: the only thing this does
* is contain the open that then fills in the correct operations
* depending on the access mode of the file...
*/
const
struct
file_operations
def_fifo_fops
=
{
.
open
=
fifo_open
,
/* will set read_ or write_pipefifo_fops */
.
llseek
=
noop_llseek
,
};
fs/pipe.c
浏览文件 @
f776c738
...
@@ -1144,6 +1144,144 @@ SYSCALL_DEFINE1(pipe, int __user *, fildes)
...
@@ -1144,6 +1144,144 @@ SYSCALL_DEFINE1(pipe, int __user *, fildes)
return
sys_pipe2
(
fildes
,
0
);
return
sys_pipe2
(
fildes
,
0
);
}
}
static
int
wait_for_partner
(
struct
inode
*
inode
,
unsigned
int
*
cnt
)
{
int
cur
=
*
cnt
;
while
(
cur
==
*
cnt
)
{
pipe_wait
(
inode
->
i_pipe
);
if
(
signal_pending
(
current
))
break
;
}
return
cur
==
*
cnt
?
-
ERESTARTSYS
:
0
;
}
static
void
wake_up_partner
(
struct
inode
*
inode
)
{
wake_up_interruptible
(
&
inode
->
i_pipe
->
wait
);
}
static
int
fifo_open
(
struct
inode
*
inode
,
struct
file
*
filp
)
{
struct
pipe_inode_info
*
pipe
;
int
ret
;
mutex_lock
(
&
inode
->
i_mutex
);
pipe
=
inode
->
i_pipe
;
if
(
!
pipe
)
{
ret
=
-
ENOMEM
;
pipe
=
alloc_pipe_info
(
inode
);
if
(
!
pipe
)
goto
err_nocleanup
;
inode
->
i_pipe
=
pipe
;
}
filp
->
f_version
=
0
;
/* We can only do regular read/write on fifos */
filp
->
f_mode
&=
(
FMODE_READ
|
FMODE_WRITE
);
switch
(
filp
->
f_mode
)
{
case
FMODE_READ
:
/*
* O_RDONLY
* POSIX.1 says that O_NONBLOCK means return with the FIFO
* opened, even when there is no process writing the FIFO.
*/
filp
->
f_op
=
&
read_pipefifo_fops
;
pipe
->
r_counter
++
;
if
(
pipe
->
readers
++
==
0
)
wake_up_partner
(
inode
);
if
(
!
pipe
->
writers
)
{
if
((
filp
->
f_flags
&
O_NONBLOCK
))
{
/* suppress POLLHUP until we have
* seen a writer */
filp
->
f_version
=
pipe
->
w_counter
;
}
else
{
if
(
wait_for_partner
(
inode
,
&
pipe
->
w_counter
))
goto
err_rd
;
}
}
break
;
case
FMODE_WRITE
:
/*
* O_WRONLY
* POSIX.1 says that O_NONBLOCK means return -1 with
* errno=ENXIO when there is no process reading the FIFO.
*/
ret
=
-
ENXIO
;
if
((
filp
->
f_flags
&
O_NONBLOCK
)
&&
!
pipe
->
readers
)
goto
err
;
filp
->
f_op
=
&
write_pipefifo_fops
;
pipe
->
w_counter
++
;
if
(
!
pipe
->
writers
++
)
wake_up_partner
(
inode
);
if
(
!
pipe
->
readers
)
{
if
(
wait_for_partner
(
inode
,
&
pipe
->
r_counter
))
goto
err_wr
;
}
break
;
case
FMODE_READ
|
FMODE_WRITE
:
/*
* O_RDWR
* POSIX.1 leaves this case "undefined" when O_NONBLOCK is set.
* This implementation will NEVER block on a O_RDWR open, since
* the process can at least talk to itself.
*/
filp
->
f_op
=
&
rdwr_pipefifo_fops
;
pipe
->
readers
++
;
pipe
->
writers
++
;
pipe
->
r_counter
++
;
pipe
->
w_counter
++
;
if
(
pipe
->
readers
==
1
||
pipe
->
writers
==
1
)
wake_up_partner
(
inode
);
break
;
default:
ret
=
-
EINVAL
;
goto
err
;
}
/* Ok! */
mutex_unlock
(
&
inode
->
i_mutex
);
return
0
;
err_rd:
if
(
!--
pipe
->
readers
)
wake_up_interruptible
(
&
pipe
->
wait
);
ret
=
-
ERESTARTSYS
;
goto
err
;
err_wr:
if
(
!--
pipe
->
writers
)
wake_up_interruptible
(
&
pipe
->
wait
);
ret
=
-
ERESTARTSYS
;
goto
err
;
err:
if
(
!
pipe
->
readers
&&
!
pipe
->
writers
)
free_pipe_info
(
inode
);
err_nocleanup:
mutex_unlock
(
&
inode
->
i_mutex
);
return
ret
;
}
/*
* Dummy default file-operations: the only thing this does
* is contain the open that then fills in the correct operations
* depending on the access mode of the file...
*/
const
struct
file_operations
def_fifo_fops
=
{
.
open
=
fifo_open
,
/* will set read_ or write_pipefifo_fops */
.
llseek
=
noop_llseek
,
};
/*
/*
* Allocate a new array of pipe buffers and copy the info over. Returns the
* Allocate a new array of pipe buffers and copy the info over. Returns the
* pipe size if successful, or return -ERROR on error.
* pipe size if successful, or return -ERROR on error.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录