LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Kernel (http://www.linuxquestions.org/questions/linux-kernel-70/)
-   -   Some questions about struct dentry involved with list (http://www.linuxquestions.org/questions/linux-kernel-70/some-questions-about-struct-dentry-involved-with-list-729605/)

ao.yuan.young 05-30-2009 11:03 PM

Some questions about struct dentry involved with list
 
In kernel-2.4.20, the attribute d_hash in struct dentry is type of list_head. So you can use function list_empty defined in list.h to check whether the hash list is empty.

But in kernel-2.6.27, the type of the attribute d_hash has been changed to hlist_node, then if you want to check whether the hash list is empty, the function list_empty will not work any more.

What should I do to solve the problem??

Another question is that there are two function concerned with hlist defined in list.h: hlist_unhash and hlist_empty. What are the differences between the two functions?

osor 05-31-2009 08:08 PM

Quote:

Originally Posted by ao.yuan.young (Post 3557886)
What should I do to solve the problem??

Instead of this (old):
Code:

if(list_empty(&d.d_hash)) foo();
Use this (new: not a “literal” translation, but the preferred usage):
Code:

if(d_unhashed(&d)) foo();
Quote:

Originally Posted by ao.yuan.young (Post 3557886)
Another question is that there are two function concerned with hlist defined in list.h: hlist_unhash and hlist_empty. What are the differences between the two functions?

The first tells if a particular node is currently “headed” by a hash. The second tells if a particular head has a node. Also, the type struct hlist_node* may be safely cast to struct hlist_head*, so the first works only on nodes, yet the second works on nodes and heads.


All times are GMT -5. The time now is 01:05 PM.