Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:inotify_read

Proto:static ssize_t inotify_read(struct file *file, char __user *buf, size_t count, loff_t *pos)

Type:ssize_t

Parameter:

TypeParameterName
struct file *file
char __user *buf
size_tcount
loff_t *pos
217  __user * start
221  start = buf
222  group = needed for tty driver, and maybe others
224  add_wait_queue( & read() on the notification file blocks on this waitq , & wait)
225  When 1 cycle
226  spin_lock( & protect the notification_list )
227  kevent = Get an fsnotify notification event if one exists and is small* enough to fit in "count". Return an error pointer if the count* is not large enough. When permission event is dequeued, its state is* updated accordingly.
228  spin_unlock( & protect the notification_list )
230  pr_debug("%s: group=%p kevent=%p\n", __func__, group, kevent)
232  If kevent Then
233  ret = PTR_ERR(kevent)
234  If IS_ERR(kevent) Then Break
238  If ret < 0 Then Break
240  buf += ret
241  count -= ret
242  Continue
245  ret = -EAGAIN
246  If f_flags & O_NONBLOCK Then Break
248  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.
249  If signal_pending(current process) Then Break
252  If start != buf Then Break
255  DEFINE_WAIT_FUNC(wait, woken_wake_func);* add_wait_queue(&wq_head, &wait);* for (;;) {* if (condition)* break;* // in wait_woken() // in woken_wake_function()* p->state = mode; wq_entry->flags |= WQ_FLAG_WOKEN;* smp_mb(); // A try_to_wake_up():* if
257  remove_wait_queue( & read() on the notification file blocks on this waitq , & wait)
259  If start != buf && ret != -EFAULT Then ret = buf - start
261  Return ret