函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source Code:fs\seq_file.c Create Date:2022-07-29 10:40:03
Last Modify:2020-03-12 14:18:49 Copyright©Brick
首页 函数Tree
注解内核,赢得工具下载SCCTEnglish

函数名称:seq_read - ->read() method for sequential files.*@file: the file to read from*@buf: the buffer to read to*@size: the maximum number of bytes to read*@ppos: the current position in the file* Ready-made ->f_op->read()

函数原型:ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)

返回类型:ssize_t

参数:

类型参数名称
struct file *file
char __user *buf
size_tsize
loff_t *ppos
155  m等于 needed for tty driver, and maybe others
156  copied等于0
159  err等于0
161  mutex_lock( & lock)
174  version等于f_version
180  如果ppos恒等于0则
181  index等于0
182  version等于0
183  count等于0
187  如果此条件成立可能性小(为编译器优化)( * ppos != read_pos)则
188 err等于traverse(m, * ppos)恒等于负EAGAIN循环
190  如果err
192  read_pos等于0
193  version等于0
194  index等于0
195  count等于0
196  转到:Done
197  否则
198  read_pos等于ppos
203  如果非buf
204  buf等于seq_buf_alloc(size = PAGE_SIZE)
205  如果非buf则转到:Enomem
209  如果count
210  n等于两数取小(count, size)
211  err等于copy_to_user(buf, buf + from, n)
212  如果err则转到:Efault
214  count减等于n
215  from加等于n
216  size减等于n
217  buf加等于n
218  copied加等于n
219  如果非size则转到:Done
223  from等于0
224  p等于start(m, & index)
225  当1循环
226  err等于错误
227  如果非p是错误退出
229  err等于show(m, p)
230  如果err小于0则退出
232  如果此条件成立可能性小(为编译器优化)(err)则count等于0
235  p等于next(m, p, & index)
236  继续下一循环
238  如果count小于size则转到:Fill
240  stop(m, p)
241  kvfree() - Free memory.*@addr: Pointer to allocated memory.* kvfree frees memory allocated by any of vmalloc(), kmalloc() or kvmalloc().* It is slightly more efficient to use kfree() or vfree() if you are certain* that you know which one to use.
242  count等于0
243  buf等于seq_buf_alloc(size <<= 1)
244  如果非buf则转到:Enomem
246  version等于0
247  p等于start(m, & index)
249  stop(m, p)
250  count等于0
251  转到:Done
252  Fill :
254  当1循环
255  offs等于count
256  pos等于index
258  p等于next(m, p, & index)
259  如果pos恒等于indexindex自加
262  如果非p是错误
263  err等于错误
264  退出
266  如果count大于等于size退出
268  err等于show(m, p)
270  count等于offs
275  stop(m, p)
276  n等于两数取小(count, size)
277  err等于copy_to_user(buf, buf, n)
278  如果err则转到:Efault
280  copied加等于n
281  count减等于n
282  from等于n
283  Done :
284  如果非copiedcopied等于err
286  否则
287  ppos加等于copied
288  read_pos加等于copied
290  f_version等于version
291  mutex_unlock - release the mutex*@lock: the mutex to be released* Unlock a mutex that has been locked by this task previously.* This function must not be used in interrupt context. Unlocking* of a not locked mutex is not allowed.
292  返回:copied
293  Enomem :
294  err等于负ENOMEM
295  转到:Done
296  Efault :
297  err等于负EFAULT
298  转到:Done