Kernel File System API d_delete, kernel apid_delete

Source: Internet
Author: User

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 );}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.