Kernel File System API d_alloc, kernel apid_alloc
D_alloc for Kernel File System APIs
Struct dentry * d_alloc (struct dentry * parent, const struct qstr * name) is used to apply for and return a dentry. The source code analysis is as follows: struct dentry * d_alloc (struct dentry * parent, const struct qstr * name) {# these first applications apply for a dentry struct dentry * dentry = _ d_alloc (parent-> d_sb, name ); # If the requested struct is null, nullif (! Dentry) return NULL; # flag value: dentry-> d_flags | = DCACHE_RCUACCESS; spin_lock (& parent-> d_lock ); /** don't need child lock because it is not subject * to concurrency here */_ dget_dlock (parent); # d_parent value dentry-> d_parent = parent; # Add this dentry to the list of parent dentry list_add (& dentry-> d_child, & parent-> d_subdirs); spin_unlock (& parent-> d_lock ); # Return the dentryreturn dentry that has been assigned a value ;}