函数逻辑报告

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

函数名称:When a process calls fcntl to attach a dnotify watch to a directory it ends* up here. Allocate both a mark for fsnotify to add and a dnotify_struct to be* attached to the fsnotify_mark.

函数原型:int fcntl_dirnotify(int fd, struct file *filp, unsigned long arg)

返回类型:int

参数:

类型参数名称
intfd
struct file *filp
unsigned longarg
255  id等于files
257  destroy等于0, error等于0
261  new_fsn_mark = NULL
262  dn = NULL
264  如果非dir_notify_enable
265  error等于负EINVAL
266  转到:out_err
270  如果arg按位与Don't remove notifier 的反的值恒等于0则
271  Called every time a file is closed. Looks first for a dnotify mark on the* inode. If one is found run all of the ->dn structures attached to that* mark for one relevant to this process closing the file and remove that* dnotify_struct
272  error等于0
273  转到:out_err
277  inode等于file_inode(filp)
278  如果非S_ISDIR(i_mode)则
279  error等于负ENOTDIR
280  转到:out_err
287  mask等于his conversion is done only at watch creation
289  error等于security_path_notify( & f_path, mask, FSNOTIFY_OBJ_TYPE_INODE)
291  如果error则转到:out_err
295  dn等于分配高速缓存区
296  如果非dn
297  error等于负ENOMEM
298  转到:out_err
302  new_dn_mark等于分配高速缓存区
303  如果非new_dn_mark
304  error等于负ENOMEM
305  转到:out_err
309  new_fsn_mark等于fsn_mark
310  Nothing fancy, just initialize lists and locks and counters.
311  Mask this mark is for [mark->lock, group->mark_mutex] 等于mask
312  dn = NULL
315  mutex_lock( & protect marks_list )
318  fsn_mark等于Given a list of marks, find the mark associated with given group. If found* take a reference to that mark and return it, else return NULL.
319  如果fsn_mark
320  dn_mark等于container_of - cast a member of a structure out to the containing structure*@ptr: the pointer to the member.*@type: the type of the container struct this is embedded in.*@member: the name of the member within the struct.(fsn_mark, structdnotify_mark, fsn_mark)
321  加自旋锁
322  否则
323  error等于fsnotify_add_inode_mark_locked(new_fsn_mark, inode, 0)
324  如果error
326  转到:out_err
328  加自旋锁
329  fsn_mark等于new_fsn_mark
330  dn_mark等于new_dn_mark
332  new_fsn_mark = NULL
335  _read_lock() - mark the beginning of an RCU read-side critical section* When synchronize_rcu() is invoked on one CPU while other CPUs* are within RCU read-side critical sections, then the* synchronize_rcu() is guaranteed to block until after all the other
336  f等于Check whether the specified fd has an open file.(fd)
337  _read_unlock() - marks the end of an RCU read-side critical section.* In most situations, rcu_read_unlock() is immune from deadlock.* However, in kernels built with CONFIG_RCU_BOOST, rcu_read_unlock()
344  如果f不等于filp
351  如果dn_mark恒等于new_dn_markdestroy等于1
353  error等于0
354  转到:out
357  __f_setown(filp, task_pid(当前进程), PIDTYPE_TGID, 0)
359  error等于If multiple processes watch the same inode with dnotify there is only one* dnotify mark in inode->i_fsnotify_marks but we chain a dnotify_struct* onto that mark. This function either attaches the new dnotify_struct onto
361  如果非errordn = NULL
365  否则如果error恒等于负EEXISTerror等于0
368  When a process starts or stops watching an inode the set of events which* dnotify cares about for that inode may change. This function runs the* list of everything receiving dnotify events about this directory and calculates* the set of all those events
369  out :
370  自旋锁解锁
372  如果destroyMark mark as detached, remove it from group list
374  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.
375  如果destroyFree fsnotify mark
377  fsnotify_put_mark(fsn_mark)
378  out_err :
379  如果new_fsn_markfsnotify_put_mark(new_fsn_mark)
381  如果dnkmem_cache_free(dnotify_struct_cache, dn)
383  返回:error
调用者
名称描述
do_fcntl