Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name: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()

Proto:ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)

Type:ssize_t

Parameter:

TypeParameterName
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  If ppos == 0 Then
181  index = 0
182  version = 0
183  count = 0
187  If Value for the false possibility is greater at compile time( * ppos != read_pos) Then
188  When (err = traverse(m, * ppos)) == -EAGAIN cycle
190  If err Then
192  read_pos = 0
193  version = 0
194  index = 0
195  count = 0
196  Go to Done
197  Else
198  read_pos = ppos
203  If Not buf Then
204  buf = seq_buf_alloc(size = PAGE_SIZE)
205  If Not buf Then Go to Enomem
209  If count Then
210  n = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(count, size)
211  err = copy_to_user(buf, buf + from, n)
212  If err Then Go to Efault
214  count -= n
215  from += n
216  size -= n
217  buf += n
218  copied += n
219  If Not size Then Go to Done
223  from = 0
224  p = start(m, & index)
225  When 1 cycle
226  err = PTR_ERR(p)
227  If Not p || IS_ERR(p) Then Break
229  err = show(m, p)
230  If err < 0 Then Break
232  If Value for the false possibility is greater at compile time(err) Then count = 0
235  p = next(m, p, & index)
236  Continue
238  If count < size Then Go to 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  If Not buf Then Go to Enomem
246  version = 0
247  p = start(m, & index)
249  stop(m, p)
250  count = 0
251  Go to Done
252  Fill :
254  When 1 cycle
255  offs = count
256  pos = index
258  p = next(m, p, & index)
259  If pos == index Then index++
262  If Not p || IS_ERR(p) Then
263  err = PTR_ERR(p)
264  Break
266  If count >= size Then Break
268  err = show(m, p)
270  count = offs
271  If Value is more likely to compile time(err <= 0) Then Break
275  stop(m, p)
276  n = min - return minimum of two values of the same or compatible types*@x: first value*@y: second value(count, size)
277  err = copy_to_user(buf, buf, n)
278  If err Then Go to Efault
280  copied += n
281  count -= n
282  from = n
283  Done :
284  If Not copied Then copied = err
286  Else
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  Return copied
293  Enomem :
294  err = -ENOMEM
295  Go to Done
296  Efault :
297  err = -EFAULT
298  Go to Done