函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:inotify_read

函数原型:static ssize_t inotify_read(struct file *file, char __user *buf, size_t count, loff_t *pos)

返回类型:ssize_t

参数:

类型参数名称
struct file *file
char __user *buf
size_tcount
loff_t *pos
217  __userstart
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  当1循环
226  加自旋锁
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  自旋锁解锁
230  pr_debug("%s: group=%p kevent=%p\n", __func__, group, kevent)
232  如果kevent
233  ret等于错误
234  如果是错误退出
238  如果ret小于0则退出
240  buf加等于ret
241  count减等于ret
242  继续下一循环
245  ret等于负EAGAIN
246  如果f_flags按位与O_NONBLOCK退出
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  如果signal_pending(当前进程)则退出
252  如果start不等于buf退出
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  如果start不等于bufret不等于负EFAULTret等于bufstart
261  返回:ret