Uclinux-2008r1-rc8 (bf561) to VDSP5 Transplantation (:D) problems arising from _alloc

Source: Internet
Author: User
Tags dname hash

There is a d_alloc function in the kernel that allocates a dentry structure and initializes it.

/**
* 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
* Copied and the copy passed in May reused the.
*/

struct Dentry *d_alloc (struct dentry * parent, const struct QSTR)
{
struct Dentry *dentry;
Char *dname;

Dentry = Kmem_cache_alloc (Dentry_cache, Gfp_kernel);
if (!dentry)
return NULL;

if (Name->len > Dname_inline_len-1) {
Dname = Kmalloc (Name->len + 1, gfp_kernel);
if (!dname) {
Kmem_cache_free (Dentry_cache, dentry);
return NULL;
}
} else {
Dname = dentry->d_iname;
}
Dentry->d_name.name = dname;

Dentry->d_name.len = name->len;
Dentry->d_name.hash = name->hash;
memcpy (Dname, Name->name, Name->len);
Dname[name->len] = 0;

Dentry->d_count.lock = 0; The newly added statement
Atomic_set (&dentry->d_count, 1);
Dentry->d_flags = dcache_unhashed;
Spin_lock_init (&dentry->d_lock);
Dentry->d_inode = NULL;
Dentry->d_parent = NULL;
DENTRY->D_SB = NULL;
Dentry->d_op = NULL;
Dentry->d_fsdata = NULL;
dentry->d_mounted = 0;
#ifdef config_profiling
Dentry->d_cookie = NULL;
#endif
Init_hlist_node (&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;
} else {
Init_list_head (&dentry->d_u.d_child);
}

Spin_lock (&dcache_lock);
if (parent)
List_add (&dentry->d_u.d_child, &parent->d_subdirs);
dentry_stat.nr_dentry++;
Spin_unlock (&dcache_lock);

return dentry;
}

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.