Subject: Re: CVS commit: [elad-kernelauth] src/sys/ufs/ext2fs
To: Jason Thorpe <thorpej@shagadelic.org>
From: Christos Zoulas <christos@zoulas.com>
List: source-changes
Date: 04/20/2006 12:17:20
On Apr 20,  9:01am, thorpej@shagadelic.org (Jason Thorpe) wrote:
-- Subject: Re: CVS commit: [elad-kernelauth] src/sys/ufs/ext2fs

| Gah, no, please.  kauth_cred_t is supposed to be an opaque type,  
| other code should not know or care that it is a pointer to a structure.

The problem with this approach is that it needs <sys/kauth.h> to be
present in all the header files that use the type. Unfortunately this
is a problem with the `c' language. There are no opaque types; for
the purist, the best you can do is to use a struct pointer which is
what the rest of the kernel does for all the data structures.

So you have the following choices:

1. Revolting hacks [actual code snippet]:

    #ifndef _UFS_FFS_FFS_EXTERN_H_
    #define _UFS_FFS_FFS_EXTERN_H_

    #ifndef HAVE_NBTOOL_CONFIG_H
    #include <sys/kauth.h>
    #else
    typedef void *kauth_cred_t;
    #endif /* !HAVE_NBTOOL_CONFIG_H */

2. Include <sys/kauth.h> everywhere and install it in userland.

3. Use "struct kauth_cred *" instead of "kauth_cred_t"

4. Rewrite the kernel in a different language.

I choose [3]; In fact, I have almost finished fixing all the header files
and adding explicit '#include <sys/kauth.h>' in the files that need it
rather than including <sys/kauth.h> in <sys/resource.h> and <sys/file.h>
so that everyone gets it by side-effect.

christos