home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] kernel hacking with data structures

  • Subject: Re: [OCLUG-Tech] kernel hacking with data structures
  • From: Bart Trojanowski <bart [ at ] jukie [ dot ] net>
  • Date: Sun, 26 Feb 2006 16:31:15 -0500
* Oren Mazor <oren [ dot ] mazor [ at ] gmail [ dot ] com> [060226 15:56]:
> Hi all,
> I'm working on some kernel modules, and I find myself needing to use
> some data structures. Since the idea is pretty ubiquitous, there's no
> real need for me to write my own implementations of hashtables.
> However, every implementation I try to use fails on compile, since
> they all use the standard c library, which is not allowed at kernel
> level coding.

Well, there are ways around this. :)  Write your own headers that
implement the library function your imlementation needs... probably just
malloc and free, right?  You can also just port it to use [kv]malloc().

> My question is, is there a standard solution to this problem, or do I
> have to [re]write these myself to use proper headers?

From what I understand, the general feeling is that you can do a better
job if your datatypes are implemented as part of the code that uses

As you know there is <linux/list.h>, which seems to be simple enough
that is can be left as a generic ADT.

There used to be a generic hash table impementation... I recall it was
quite buggy.  From the looks of it, it has been removed since I used it

Certain parts of linux implement their private, but abstract types.
Just looking through the sources I found security/selinux/ss/hashtab.h
which looks good enough for day-to-day use.

Good luck.


				WebSig: http://www.jukie.net/~bart/sig/

Attachment: signature.asc
Description: Digital signature