Function report

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

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

Name:vfs_rename - rename a filesystem object*@old_dir: parent of source*@old_dentry: source*@new_dir: parent of destination*@new_dentry: destination*@delegated_inode: returns an inode needing a delegation break*@flags: rename flags

Proto:int vfs_rename(struct inode *old_dir, struct dentry *old_dentry, struct inode *new_dir, struct dentry *new_dentry, struct inode **delegated_inode, unsigned int flags)

Type:int

Parameter:

TypeParameterName
struct inode *old_dir
struct dentry *old_dentry
struct inode *new_dir
struct dentry *new_dentry
struct inode **delegated_inode
unsigned intflags
4339  is_dir = d_is_dir(old_dentry)
4340  source = Where the name belongs to - NULL is * negative
4341  target = Where the name belongs to - NULL is * negative
4342  bool new_is_dir = false
4343  max_links = s_max_links
4346  If source == target Then Return 0
4349  error = Check whether we can remove a link victim from directory dir, check* whether the type of victim is right.* 1. We can't do it if dir is read-only (done in permission())* 2. We should have write and exec permissions on dir* 3
4350  If error Then Return error
4353  If Not target Then
4354  error = Check whether we can create an object with dentry child in directory* dir.* 1. We can't do it if child already exists (open has special treatment for* this case, but since we are inlined it's OK)* 2
4355  Else
4356  new_is_dir = d_is_dir(new_dentry)
4358  If Not (flags & Exchange source and dest ) Then error = Check whether we can remove a link victim from directory dir, check* whether the type of victim is right.* 1. We can't do it if dir is read-only (done in permission())* 2. We should have write and exec permissions on dir* 3
4360  Else error = Check whether we can remove a link victim from directory dir, check* whether the type of victim is right.* 1. We can't do it if dir is read-only (done in permission())* 2. We should have write and exec permissions on dir* 3
4363  If error Then Return error
4366  If Not rename Then Return -EPERM
4373  If new_dir != old_dir Then
4374  If is_dir Then
4376  If error Then Return error
4381  If error Then Return error
4386  error = security_inode_rename(old_dir, old_dentry, new_dir, new_dentry, flags)
4388  If error Then Return error
4391  take_dentry_name_snapshot( & old_name, old_dentry)
4392  get a reference to a dentry
4393  If Not is_dir || flags & Exchange source and dest Then lock_two_nondirectories(source, target)
4395  Else if target Then inode_lock(target)
4398  error = -EBUSY
4399  If is_local_mountpoint(old_dentry) || is_local_mountpoint(new_dentry) Then Go to out
4402  If max_links && new_dir != old_dir Then
4403  error = -EMLINK
4404  If is_dir && Not new_is_dir && i_nlink >= max_links Then Go to out
4406  If flags & Exchange source and dest && Not is_dir && new_is_dir && i_nlink >= max_links Then Go to out
4410  If Not is_dir Then
4411  error = try_break_deleg(source, delegated_inode)
4412  If error Then Go to out
4415  If target && Not new_is_dir Then
4416  error = try_break_deleg(target, delegated_inode)
4417  If error Then Go to out
4420  error = rename(old_dir, old_dentry, new_dir, new_dentry, flags)
4422  If error Then Go to out
4425  If Not (flags & Exchange source and dest ) && target Then
4426  If is_dir Then
4427  prune dcache
4430  dont_mount(new_dentry)
4431  detach_mounts(new_dentry)
4433  If Not (fs_flags & FS will handle d_move() during rename() internally. ) Then
4434  If Not (flags & Exchange source and dest ) Then move a dentry
4436  Else d_exchange(old_dentry, new_dentry)
4439  out :
4440  If Not is_dir || flags & Exchange source and dest Then unlock_two_nondirectories(source, target)
4442  Else if target Then inode_unlock(target)
4444  dput(new_dentry)
4445  If Not error Then
4446  snotify_move - file old_name at old_dir was moved to new_name at new_dir
4453  release_dentry_name_snapshot( & old_name)
4455  Return error
Caller
NameDescribe
do_renameat2