Kernel File System API d_delete, kernel apid_delete
D_delete of Kernel File System API
Void d_delete (struct dentry * dentry) is used to delete a dentry. The source code analysis is as follows: void d_delete (struct dentry * dentry) {struct inode * inode; int isdir = 0; /** Are we the only user? */Again: spin_lock (& dentry-> d_lock); inode = dentry-> d_inode; # check whether this dentry is a directory's dentryisdir = S_ISDIR (inode-> I _mode ); # if only one dentry user is used at present, the system tries to obtain the lock. if the acquisition fails, the goto loop is used to continue to try to obtain if (dentry-> d_lockref.count = 1) {if (! Spin_trylock (& inode-> I _lock) {spin_unlock (& dentry-> d_lock); cpu_relax (); goto again;} # after obtaining the lock, clear the DCACHE_CANT_MOUNT flag dentry-> d_flags & = ~ DCACHE_CANT_MOUNT; dentry_unlink_inode (dentry); # notify the dentry to delete the directory fsnotify_nameremove (dentry, isdir); return ;}# if dentry uses more than one user, then try to drop the operation if (! D_unhashed (dentry) _ d_drop (dentry); spin_unlock (& dentry-> d_lock); # notify this to delete the directory fsnotify_nameremove (dentry, isdir) indicated by dentry );} the implementation of fsnotify_nameremove is as follows: static inline void fsnotify_nameremove (struct dentry * dentry, int isdir) {__ u32 mask = FS_DELETE; # If the dentry to be deleted is a directory, add FS_ISDIRif (isdir) mask | = FS_ISDIR; # notify the dentry parent dentry of the event fsnotify_parent (NULL, dentry, mask );}