kernels/linux-2.4.0/fs/dcache.c
/**
 * d_alloc	-	allocate a dcache entry
 * @parent: parent of entry to allocate
 * @name: qstr of the name
 *
 * Allocates a dentry. It returns %NULL if there is insufficient memory
 * available. On a success the dentry is returned. The name passed in is
 * copied and the copy passed in may be reused after this call.
 */
d_alloc      -       allocate a dcache entry
@parent: parent of entry to allocate
@name: qstr of the name

Allocates a dentry. It returns %NULL if there is insufficient memory
available. On a success the dentry is returned. The name passed in is
copied and the copy passed in may be reused after this call.
d_alloc - allocate a dcache entry @parent : parent of entry to allocate @name : qstr of the name Allocates a dentry . It returns %NULL if there is insufficient memory available . On a success the dentry is returned . The name passed in is copied and the copy passed in may be reused after this call .
struct dentry * d_alloc(struct dentry * parent, const struct qstr *name)
{
	char * str;
	struct dentry *dentry;
	dentry = kmem_cache_alloc(dentry_cache, GFP_KERNEL); 
	if (!dentry)
		return NULL;
	if (name->len > DNAME_INLINE_LEN-1) {
		str = kmalloc(NAME_ALLOC_LEN(name->len), GFP_KERNEL);
		if (!str) {
			kmem_cache_free(dentry_cache, dentry); 
			return NULL;
		}
	} else
		str = dentry->d_iname; 
	memcpy(str, name->name, name->len);
	str[name->len] = 0;
	atomic_set(&dentry->d_count, 1);
	dentry->d_flags = 0;
	dentry->d_inode = NULL;
	dentry->d_parent = NULL;
	dentry->d_sb = NULL;
	dentry->d_name.name = str;
	dentry->d_name.len = name->len;
	dentry->d_name.hash = name->hash;
	dentry->d_op = NULL;
	dentry->d_fsdata = NULL;
	INIT_LIST_HEAD(&dentry->d_vfsmnt);
	INIT_LIST_HEAD(&dentry->d_hash);
	INIT_LIST_HEAD(&dentry->d_lru);
	INIT_LIST_HEAD(&dentry->d_subdirs);
	INIT_LIST_HEAD(&dentry->d_alias);
	if (parent) {
		dentry->d_parent = dget(parent);
		dentry->d_sb = parent->d_sb;
		spin_lock(&dcache_lock);
		list_add(&dentry->d_child, &parent->d_subdirs);
		spin_unlock(&dcache_lock);
	} else
		INIT_LIST_HEAD(&dentry->d_child);
	dentry_stat.nr_dentry++;
	return dentry;
}
struct dentry * d_alloc ( struct dentry * parent , const struct qstr * name ) { char * str ; struct dentry * dentry ; dentry = kmem_cache_alloc ( dentry_cache , GFP_KERNEL ) ; if ( ! dentry ) return NULL ; if ( name -> len > DNAME_INLINE_LEN - 1 ) { str = kmalloc ( NAME_ALLOC_LEN ( name -> len ) , GFP_KERNEL ) ; if ( ! str ) { kmem_cache_free ( dentry_cache , dentry ) ; return NULL ; } } else str = dentry -> d_iname ; memcpy ( str , name -> name , name -> len ) ; str [ name -> len ] = 0 ; atomic_set ( & dentry -> d_count , 1 ) ; dentry -> d_flags = 0 ; dentry -> d_inode = NULL ; dentry -> d_parent = NULL ; dentry -> d_sb = NULL ; dentry -> d_name . name = str ; dentry -> d_name . len = name -> len ; dentry -> d_name . hash = name -> hash ; dentry -> d_op = NULL ; dentry -> d_fsdata = NULL ; INIT_LIST_HEAD ( & dentry -> d_vfsmnt ) ; INIT_LIST_HEAD ( & dentry -> d_hash ) ; INIT_LIST_HEAD ( & dentry -> d_lru ) ; INIT_LIST_HEAD ( & dentry -> d_subdirs ) ; INIT_LIST_HEAD ( & dentry -> d_alias ) ; if ( parent ) { dentry -> d_parent = dget ( parent ) ; dentry -> d_sb = parent -> d_sb ; spin_lock ( & dcache_lock ) ; list_add ( & dentry -> d_child , & parent -> d_subdirs ) ; spin_unlock ( & dcache_lock ) ; } else INIT_LIST_HEAD ( & dentry -> d_child ) ; dentry_stat . nr_dentry ++ ; return dentry ; }
d_alloc      -       allocate a dcache entry
 @parent: parent of entry to allocate
 @name: qstr of the name
d_alloc - allocate a dcache entry @parent : parent of entry to allocate @name : qstr of the name