Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Look up and maybe create and open the last component

Proto:static int lookup_open(struct nameidata *nd, struct path *path, struct file *file, const struct open_flags *op, bool got_write)

Type:int

Parameter:

TypeParameterName
struct nameidata *nd
struct path *path
struct file *file
const struct open_flags *op
boolgot_write
3076  dir = dentry
3077  dir_inode = Where the name belongs to - NULL is * negative
3078  open_flag = open_flag
3080  create_error = 0
3081  mode = mode
3082  DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wq)
3084  If Value for the false possibility is greater at compile time(IS_DEADDIR(dir_inode)) Then Return -ENOENT
3087  f_mode &= ~FMODE_CREATED
3088  dentry = search for a dentry
3089  cycle
3090  If Not dentry Then
3091  dentry = d_alloc_parallel(dir, & last, & wq)
3092  If IS_ERR(dentry) Then Return PTR_ERR(dentry)
3095  If d_in_lookup(dentry) Then Break
3098  error = d_revalidate(dentry, flags)
3099  If Value is more likely to compile time(error > 0) Then Break
3101  If error Then Go to out_dput
3103  invalidate a dentry
3104  dput(dentry)
3105  dentry = NULL
3107  If Where the name belongs to - NULL is * negative Then
3109  Go to out_no_open
3121  If open_flag & O_CREAT Then
3122  If Not IS_POSIXACL( Where the name belongs to - NULL is * negative ) Then mode &= ~current_umask()
3125  create_error = -EROFS
3126  open_flag &= ~O_CREAT
3127  If open_flag & (O_EXCL | O_TRUNC) Then Go to no_open
3130  Else
3132  If create_error Then
3133  open_flag &= ~O_CREAT
3134  If open_flag & O_EXCL Then Go to no_open
3138  Else if open_flag & ( O_TRUNC | O_WRONLY | O_RDWR) && Value for the false possibility is greater at compile time(!got_write) Then
3144  Go to no_open
3147  If atomic_open Then
3148  error = Attempt to atomically look up, create and open a file from a negative* dentry
3150  If Value for the false possibility is greater at compile time(error == - ENOENT) && create_error Then error = create_error
3152  Return error
3155  no_open :
3156  If d_in_lookup(dentry) Then
3157  res = lookup(dir_inode, dentry, flags)
3159  d_lookup_done(dentry)
3161  If IS_ERR(res) Then
3162  error = PTR_ERR(res)
3163  Go to out_dput
3165  dput(dentry)
3166  dentry = res
3171  If Not Where the name belongs to - NULL is * negative && open_flag & O_CREAT Then
3172  f_mode |= FMODE_CREATED
3173  audit_inode_child(dir_inode, dentry, a child being created )
3174  If Not create Then
3175  error = -EACCES
3176  Go to out_dput
3178  error = create(dir_inode, dentry, mode, open_flag & O_EXCL)
3180  If error Then Go to out_dput
3182  snotify_create - 'name' was linked in
3184  If Value for the false possibility is greater at compile time(create_error) && Not Where the name belongs to - NULL is * negative Then
3185  error = create_error
3186  Go to out_dput
3188  out_no_open :
3189  dentry = dentry
3190  mnt = mnt
3191  Return 0
3193  out_dput :
3194  dput(dentry)
3195  Return error
Caller
NameDescribe
do_lastHandle the last step of open()