Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:anotify syscalls

Proto:SYSCALL_DEFINE2(fanotify_init, unsigned int, flags, unsigned int, event_f_flags)

Type:

Parameter:Nothing

773  pr_debug("%s: flags=%x event_f_flags=%x\n", __func__, flags, event_f_flags)
776  If Not Check operation authority Then Return -EPERM
782  If flags & ~FANOTIFY_INIT_FLAGS Then Return -EINVAL
786  If event_f_flags & ~All flags that may be specified in parameter event_f_flags of fanotify_init Then Return -EINVAL
790  Case & == O_RDONLY
791  Case & == O_RDWR
792  Case & == O_WRONLY
793  Break
794  Default
795  Return -EINVAL
798  If flags & Report unique file id && (flags & Flags allowed to be passed from/to userspace) != These are NOT bitwise flags. Both bits are used together. Then Return -EINVAL
802  user = get_current_user - Get the current task's user_struct* Get the user record of the current task, pinning it so that it can't go* away.()
803  If atomic_read( & fanotify_listeners) > FANOTIFY_DEFAULT_MAX_LISTENERS Then
804  free_uid(user)
805  Return -EMFILE
808  f_flags = O_RDWR | File was opened by fanotify and shouldn't generate fanotify events
809  If flags & lags used for fanotify_init() Then f_flags |= O_CLOEXEC
811  If flags & FAN_NONBLOCK Then f_flags |= O_NONBLOCK
815  group = Create a new fsnotify_group and hold a reference for the group returned.
816  If IS_ERR(group) Then
817  free_uid(user)
818  Return PTR_ERR(group)
821  user = user
822  flags = flags
823  atomic_inc( & fanotify_listeners)
824  memcg to charge allocations = get_mem_cgroup_from_mm: Obtain a reference on given mm_struct's memcg.*@mm: mm from which memcg should be extracted. It can be NULL.* Obtain a reference on mm->memcg and returns it if successful. Otherwise* root_mem_cgroup is returned
826  oevent = fanotify_alloc_event(group, NULL, Event queued overflowed , NULL, when calling fsnotify tell it if the data is a path or inode , NULL)
828  If Value for the false possibility is greater at compile time(!oevent) Then
829  fd = -ENOMEM
830  Go to out_destroy_group
832  Event we queue when the * notification list is too * full = fse
834  If force_o_largefile() Then event_f_flags |= O_LARGEFILE
836  f_flags = event_f_flags
837  init_waitqueue_head( & access_waitq)
838  Initialization list head
840  Case & == These are NOT bitwise flags. Both bits are used together.
841  priority = rmal notifiers, no permissions
842  Break
843  Case & == FAN_CLASS_CONTENT
844  priority = anotify content based access control
845  Break
846  Case & == FAN_CLASS_PRE_CONTENT
847  priority = anotify pre-content access
848  Break
849  Default
850  fd = -EINVAL
851  Go to out_destroy_group
854  If flags & FAN_UNLIMITED_QUEUE Then
855  fd = -EPERM
856  If Not Check operation authority Then Go to out_destroy_group
858  maximum events allowed on the list = UINT_MAX
859  Else
860  maximum events allowed on the list = FANOTIFY_DEFAULT_MAX_EVENTS
863  If flags & FAN_UNLIMITED_MARKS Then
864  fd = -EPERM
865  If Not Check operation authority Then Go to out_destroy_group
867  max_marks = UINT_MAX
868  Else
869  max_marks = FANOTIFY_DEFAULT_MAX_MARKS
872  If flags & FAN_ENABLE_AUDIT Then
873  fd = -EPERM
874  If Not Check operation authority Then Go to out_destroy_group
878  fd = anon_inode_getfd - creates a new file instance by hooking it up to an* anonymous inode, and a dentry that describe the "class"* of the file*@name: [in] name of the "class" of the new file*@fops: [in] file operations for the new file*@priv: [in] private
879  If fd < 0 Then Go to out_destroy_group
882  Return fd
884  out_destroy_group :
885  Trying to get rid of a group. Remove all marks, flush all events and release* the group reference.* Note that another thread calling fsnotify_clear_marks_by_group() may still* hold a ref to the group.
886  Return fd