Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:Handle the last step of open()

Proto:static int do_last(struct nameidata *nd, struct file *file, const struct open_flags *op)

Type:int

Parameter:

TypeParameterName
struct nameidata *nd
struct file *file
const struct open_flags *op
3204  dir = dentry
3205  dir_uid = i_uid
3206  dir_mode = i_mode
3207  open_flag = open_flag
3208  will_truncate = (open_flag & O_TRUNC) != 0
3209  bool got_write = false
3210  acc_mode = acc_mode
3216  flags &= ~rnal use only
3217  flags |= intent
3219  If last_type != LAST_NORM Then
3220  error = handle_dots(nd, last_type)
3221  If Value for the false possibility is greater at compile time(error) Then Return error
3223  Go to finish_open
3226  If Not (open_flag & O_CREAT) Then
3227  If name[len] Then flags |= llow links at the end | quire a directory
3230  error = lookup_fast(nd, & path, & inode, & seq)
3231  If Value is more likely to compile time(error > 0) Then Go to finish_lookup
3234  If error < 0 Then Return error
3237  BUG_ON( path.dentry.d_inode != Where the name belongs to - NULL is * negative )
3238  BUG_ON(flags & RCU pathwalk mode; semi-internal )
3239  Else
3246  error = mplete_walk - successful completion of path walk*@nd: pointer nameidata* If we had been in RCU mode, drop out of it and legitimize nd->path.* Revalidate the final result, unless we'd already done that during
3247  If error Then Return error
3250  audit_inode(name, dir, dentry represents the parent )
3252  If Value for the false possibility is greater at compile time(name[len]) Then Return -EISDIR
3256  If open_flag & ( O_CREAT | O_TRUNC | O_WRONLY | O_RDWR) Then
3257  error = mnt_want_write(mnt)
3258  If Not error Then got_write = true
3266  If open_flag & O_CREAT Then inode_lock( Where the name belongs to - NULL is * negative )
3268  Else inode_lock_shared( Where the name belongs to - NULL is * negative )
3270  error = Look up and maybe create and open the last component
3271  If open_flag & O_CREAT Then inode_unlock( Where the name belongs to - NULL is * negative )
3273  Else inode_unlock_shared( Where the name belongs to - NULL is * negative )
3276  If error Then Go to out
3279  If f_mode & FMODE_OPENED Then
3280  If f_mode & FMODE_CREATED || Not S_ISREG(i_mode) Then will_truncate = false
3284  audit_inode(name, dentry, 0)
3285  Go to opened
3288  If f_mode & FMODE_CREATED Then
3290  open_flag &= ~O_TRUNC
3291  will_truncate = false
3292  acc_mode = 0
3293  path_to_nameidata( & path, nd)
3294  Go to finish_open_created
3302  If got_write Then
3303  mnt_drop_write(mnt)
3304  got_write = false
3307  error = Handle a dentry that is managed in some way.* - Flagged for transit management (autofs)* - Flagged as mountpoint* - Flagged as automount point* This may only be called in refwalk mode.* On success path->dentry is known positive.
3308  If Value for the false possibility is greater at compile time(error < 0) Then Return error
3314  audit_inode(name, dentry, 0)
3316  If Value for the false possibility is greater at compile time((open_flag & (O_EXCL | O_CREAT)) == (O_EXCL | O_CREAT)) Then
3317  path_to_nameidata( & path, nd)
3318  Return -EEXIST
3321  seq = 0
3322  inode = d_backing_inode - Get upper or lower inode we should be using*@upper: The upper layer* This is the helper that should be used to get at the inode that will be used* if this dentry were to be opened as a file. The inode may be on the upper
3323  finish_lookup :
3324  error = Do we need to follow links? We _really_ want to be able* to do this check without having to look at inode->i_op,* so we keep a cache of "no, this doesn't need follow_link"* for the common case.
3325  If Value for the false possibility is greater at compile time(error) Then Return error
3327  finish_open :
3329  error = mplete_walk - successful completion of path walk*@nd: pointer nameidata* If we had been in RCU mode, drop out of it and legitimize nd->path.* Revalidate the final result, unless we'd already done that during
3330  If error Then Return error
3332  audit_inode(name, dentry, 0)
3333  If open_flag & O_CREAT Then
3334  error = -EISDIR
3335  If d_is_dir(dentry) Then Go to out
3337  error = may_create_in_sticky - Check whether an O_CREAT open in a sticky directory* should be allowed, or not, on files that already* exist
3339  If Value for the false possibility is greater at compile time(error) Then Go to out
3342  error = -ENOTDIR
3343  If flags & quire a directory && Not d_can_lookup(dentry) Then Go to out
3345  If Not d_is_reg(dentry) Then will_truncate = false
3348  If will_truncate Then
3349  error = mnt_want_write(mnt)
3350  If error Then Go to out
3352  got_write = true
3354  finish_open_created :
3355  error = may_open( & path, acc_mode, open_flag)
3356  If error Then Go to out
3358  BUG_ON(f_mode & FMODE_OPENED)
3359  error = vfs_open - open the file at the given path*@path: path to open*@file: newly allocated file with f_flag initialized*@cred: credentials to use
3360  If error Then Go to out
3362  opened :
3363  error = ima_file_check(file, acc_mode)
3364  If Not error && will_truncate Then error = handle_truncate(file)
3366  out :
3367  If Value for the false possibility is greater at compile time(error > 0) Then
3368  WARN_ON(1)
3369  error = -EINVAL
3371  If got_write Then mnt_drop_write(mnt)
3373  Return error
Caller
NameDescribe
path_openat