LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices



Reply
 
Search this Thread
Old 05-31-2009, 12:03 AM   #1
ao.yuan.young
LQ Newbie
 
Registered: May 2009
Posts: 12

Rep: Reputation: 0
Question 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?
 
Old 05-31-2009, 09:08 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by ao.yuan.young View Post
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 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Typecast struct sockaddr in struct sockaddr_in sudhansu Linux - Kernel 1 02-17-2009 11:33 AM
GCC compile problem:struct A have a member variable which is just a struct type name? leon.zcom Programming 3 04-18-2008 05:40 PM
c linked list wiht struct true_atlantis Programming 7 04-24-2006 07:21 PM
g++ and wrong struct member addresses / struct size misreporting sonajiso Linux - General 5 05-22-2004 11:16 PM
switch statement converting struct char to struct int oceaneyes2 Programming 2 12-10-2003 05:30 PM


All times are GMT -5. The time now is 08:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration