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

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

I actually did write my own since I sent that email, but since I'm
pressed for time with this, I'll switch to the hashtab.h version for
now.

thanks muchly :)

Oren

On 2/26/06, Bart Trojanowski <bart [ at ] jukie [ dot ] net> wrote:
> * 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
> them.
>
> 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
> last.
>
> 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.
>
> -Bart
>
> --
>                                 WebSig: http://www.jukie.net/~bart/sig/
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.1 (GNU/Linux)
>
> iD8DBQFEAh4j/zRZ1SKJaI8RAjVQAJwLnr6JhyCcHbfsH8Y2ZWPpbcA0jgCfZlUj
> AbO9eQazM3i2WwketAXE10c=
> =Ewu9
> -----END PGP SIGNATURE-----
>
>
>