Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\pipe.c Create Date:2022-07-28 20:04:31
Last Modify:2020-03-12 14:18:49 Copyright©Brick
home page Tree
Annotation kernel can get tool activityDownload SCCTChinese

Name:fifo_open

Proto:static int fifo_open(struct inode *inode, struct file *filp)

Type:int

Parameter:

TypeParameterName
struct inode *inode
struct file *filp
1016  is_pipe = s_magic == PIPEFS_MAGIC
1019  f_version = 0
1021  spin_lock( & _blocks, i_bytes, maybe i_size )
1022  If i_pipe Then
1023  pipe = i_pipe
1024  files++
1025  spin_unlock( & _blocks, i_bytes, maybe i_size )
1026  Else
1027  spin_unlock( & _blocks, i_bytes, maybe i_size )
1028  pipe = alloc_pipe_info()
1029  If Not pipe Then Return -ENOMEM
1031  files = 1
1032  spin_lock( & _blocks, i_bytes, maybe i_size )
1034  files++
1037  pipe = i_pipe
1038  Else
1039  i_pipe = pipe
1043  needed for tty driver, and maybe others = pipe
1046  __pipe_lock(pipe)
1049  stream_open is used by subsystems that want stream-like file descriptors.* Such file descriptors are not seekable and don't have notion of position* (file.f_pos is always 0 and ppos passed to .read()/.write() is always NULL).
1052  Case & == le is open for reading
1058  r_counter++
1059  If readers++ == 0 Then wake_up_partner(pipe)
1062  If Not is_pipe && Not writers Then
1063  If f_flags & O_NONBLOCK Then
1066  f_version = w_counter
1067  Else
1068  If wait_for_partner(pipe, & w_counter) Then Go to err_rd
1072  Break
1074  Case & == le is open for writing
1080  ret = -ENXIO
1081  If Not is_pipe && f_flags & O_NONBLOCK && Not readers Then Go to err
1084  w_counter++
1085  If Not writers ++ Then wake_up_partner(pipe)
1088  If Not is_pipe && Not readers Then
1089  If wait_for_partner(pipe, & r_counter) Then Go to err_wr
1092  Break
1094  Case & == le is open for reading | le is open for writing
1102  readers++
1103  writers++
1104  r_counter++
1105  w_counter++
1106  If readers == 1 || writers == 1 Then wake_up_partner(pipe)
1108  Break
1110  Default
1111  ret = -EINVAL
1112  Go to err
1116  __pipe_unlock(pipe)
1117  Return 0
1119  err_rd :
1120  If Not --readers Then wake_up_interruptible( & wait)
1122  ret = -These should never be seen by user programs. To return one of ERESTART** codes, signal_pending() MUST be set. Note that ptrace can observe these* at syscall exit tracing, but they will never be left for the debugged user* process to see.
1123  Go to err
1125  err_wr :
1126  If Not --writers Then wake_up_interruptible( & wait)
1128  ret = -These should never be seen by user programs. To return one of ERESTART** codes, signal_pending() MUST be set. Note that ptrace can observe these* at syscall exit tracing, but they will never be left for the debugged user* process to see.
1129  Go to err
1131  err :
1132  __pipe_unlock(pipe)
1134  put_pipe_info(inode, pipe)
1135  Return ret