From: Cheyenne Wills Date: Tue, 11 Jan 2022 01:11:58 +0000 (-0700) Subject: afs.h: fix out of tree build failures X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=92342b099dd5ea539efc5ad119d36a87647c0895 afs.h: fix out of tree build failures There are several compiler errors and warnings when building an out of tree program that includes "afs/afs.h". - Errors for unknown type names 'afs_ucred_t' and 'wait_queue_head' .../afs/afs.h:1542:16: error: unknown type name ‘afs_ucred_t’ ... | afs_set_cr_uid(afs_ucred_t *cred, uid_t uid) { .../afs/afs.h:1605:5: error: unknown type name ‘wait_queue_head_t’ ... | wait_queue_head_t cond; - Warnings about declaring structures within missing declarations for the structs: osi_File, dcache and afs_FetchOutput .../afs/afs.h:1486:36: warning: ‘struct osi_file’ declared inside parameter list will not be visible outside of this definition or declaration ... | int (*read)(void *rock, struct osi_file *tfile, afs_uint32 offset, - Unable to find the file for the include opr/jhash.h The missing type name 'afs_ucred_t' is due to miss-placed declarations for some kernel only functions. The type name 'wait_queue_head' is a data type for Linux kernel modules. The warnings for the missing declarations are due to either references to the structures before they are declared, or because they are not available in any of the other public header files. To fix the unknown type name afs_ucred_t, relocate the function declarations that reference 'afs_ucred_t' into the KERNEL only section (since afs_ucred_t is a kernel specific type). To fix the unknown type name 'wait_queue_head', relocate the afs_event structure and the afs_evhasht variable to be within the KERNEL only section. To resolve the warnings associated with the structures, simply declare the structure names before they are referenced. All references that are resulting in the warnings are declarations for pointers. Relocate the include for opr/jhash.h and the define for VCSIZE into the kernel block. Change-Id: I4135ff25b76d3221c7779c279ed829000ce31f1c Reviewed-on: https://gerrit.openafs.org/14857 Tested-by: BuildBot Reviewed-by: Andrew Deason Reviewed-by: Benjamin Kaduk --- diff --git a/src/afs/afs.h b/src/afs/afs.h index 7e5a572..544e5d2 100644 --- a/src/afs/afs.h +++ b/src/afs/afs.h @@ -15,9 +15,6 @@ #include "afs/afs_args.h" #include "afs/afs_consts.h" -/* jhash.h is a standalone header and is fine to pull into kernel code. */ -#include - /* * afs_fsfragsize cannot be less than 1023, or some cache-tracking * calculations will be incorrect (since we track cache usage in kb). @@ -100,7 +97,6 @@ extern enum afs_shutdown_state afs_shuttingdown; #define NVOLS 64 /* hash table size for volume table */ #define NFENTRIES 256 /* hash table size for disk volume table */ #define VCSIZEBITS 16 /* log of stat cache hash table size */ -#define VCSIZE (opr_jhash_size(VCSIZEBITS)) #define CBRSIZE 512 /* call back returns hash table size */ #define PIGGYSIZE 1350 /* max piggyback size */ #define MAXVOLS 128 /* max vols we can store */ @@ -138,8 +134,15 @@ struct sysname_info { /* flags to use with AFSOP_CACHEINIT */ #define AFSCALL_INIT_MEMCACHE 0x1 /* use a memory-based cache */ +struct dcache; + /* below here used only for kernel procedures */ #ifdef KERNEL + +#include + +#define VCSIZE (opr_jhash_size(VCSIZEBITS)) + /* Store synchrony flags - SYNC means that data should be forced to server's * disk immediately upon completion. */ #define AFS_ASYNC 0 @@ -1388,6 +1391,78 @@ extern struct brequest afs_brs[NBRS]; /* request structures */ #define AFS_VOLCHECK_MTPTS 0x4 /* mount point invalidation also */ #define AFS_VOLCHECK_FORCE 0x8 /* do all forcibly */ +/* + * Wrappers for access to credentials structure members + * Linux uses the kernel cred structure if available, with the + * wrappers defined in LINUX/osi_machdep.h + */ +#if defined(AFS_NBSD40_ENV) +/* in osi_machdep.h as expected */ +#elif defined (AFS_DARWIN110_ENV) +#define afs_cr_uid(cred) kauth_cred_getuid((kauth_cred_t)(cred)) +#define afs_cr_gid(cred) kauth_cred_getgid((kauth_cred_t)(cred)) +#elif !(defined(AFS_LINUX_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)) +#define afs_cr_uid(cred) ((cred)->cr_uid) +#define afs_cr_gid(cred) ((cred)->cr_gid) +#if !defined(AFS_OBSD_ENV) +#define afs_cr_ruid(cred) ((cred)->cr_ruid) +#define afs_cr_rgid(cred) ((cred)->cr_rgid) +#endif + +#if !defined(AFS_DARWIN110_ENV) +static_inline void +afs_set_cr_uid(afs_ucred_t *cred, uid_t uid) { + cred->cr_uid = uid; +} +static_inline void +afs_set_cr_gid(afs_ucred_t *cred, gid_t gid) { + cred->cr_gid = gid; +} +#if !defined(AFS_OBSD_ENV) +static_inline void +afs_set_cr_ruid(afs_ucred_t *cred, uid_t uid) { + cred->cr_ruid = uid; +} +static_inline void +afs_set_cr_rgid(afs_ucred_t *cred, gid_t gid) { + cred->cr_rgid = gid; +} +#endif /* ! AFS_OBSD_ENV */ +#endif /* ! AFS_DARWIN110_ENV */ +#endif + +/* + * Various definitions for osi_sleep and its event hash table + * DFBSD has no osi_sleep, and HPUX has its own hack for this stuff + */ +#define AFS_EVHASHSIZE 128 /* size of afs_evhasht, must be power of 2 */ + +typedef struct afs_event { + struct afs_event *next; /* next in hash chain */ + char *event; /* lwp event: an address */ + int refcount; /* Is it in use? */ + int seq; /* Sequence number: this is incremented + * by wakeup calls; wait will not return until + * it changes */ +#if defined(AFS_AIX_ENV) + tid_t cond; +#elif defined(AFS_DARWIN_ENV) +# ifdef AFS_DARWIN80_ENV + lck_mtx_t *lck; + thread_t owner; +# endif + /* no cond member */ +#elif defined(AFS_FBSD_ENV) || defined(AFS_OBSD_ENV) + int cond; /* "all this gluck should probably be replaced by CVs" */ +#elif defined(AFS_LINUX_ENV) + wait_queue_head_t cond; +#elif defined(AFS_NBSD_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) + kcondvar_t cond; /* Currently associated condition variable */ +#endif +} afs_event_t; + +extern afs_event_t *afs_evhasht[AFS_EVHASHSIZE]; /* Hash table for events */ + #endif /* KERNEL */ #define AFS_FSPORT ((unsigned short) htons(7000)) @@ -1470,6 +1545,8 @@ extern struct brequest afs_brs[NBRS]; /* request structures */ except with libuafs, in which case it is actually defined */ struct buf; +struct osi_file; +struct afs_FetchOutput; struct rxfs_storeVariables { struct rx_call *call; @@ -1519,46 +1596,6 @@ extern int afs_fakestat_enable; extern int afs_rmtsys_enable; extern int afsd_dynamic_vcaches; -/* - * Wrappers for access to credentials structure members - * Linux uses the kernel cred structure if available, with the - * wrappers defined in LINUX/osi_machdep.h - */ -#if defined(AFS_NBSD40_ENV) -/* in osi_machdep.h as expected */ -#elif defined (AFS_DARWIN110_ENV) -#define afs_cr_uid(cred) kauth_cred_getuid((kauth_cred_t)(cred)) -#define afs_cr_gid(cred) kauth_cred_getgid((kauth_cred_t)(cred)) -#elif !(defined(AFS_LINUX_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)) -#define afs_cr_uid(cred) ((cred)->cr_uid) -#define afs_cr_gid(cred) ((cred)->cr_gid) -#if !defined(AFS_OBSD_ENV) -#define afs_cr_ruid(cred) ((cred)->cr_ruid) -#define afs_cr_rgid(cred) ((cred)->cr_rgid) -#endif - -#if !defined(AFS_DARWIN110_ENV) -static_inline void -afs_set_cr_uid(afs_ucred_t *cred, uid_t uid) { - cred->cr_uid = uid; -} -static_inline void -afs_set_cr_gid(afs_ucred_t *cred, gid_t gid) { - cred->cr_gid = gid; -} -#if !defined(AFS_OBSD_ENV) -static_inline void -afs_set_cr_ruid(afs_ucred_t *cred, uid_t uid) { - cred->cr_ruid = uid; -} -static_inline void -afs_set_cr_rgid(afs_ucred_t *cred, gid_t gid) { - cred->cr_rgid = gid; -} -#endif /* ! AFS_OBSD_ENV */ -#endif /* ! AFS_DARWIN110_ENV */ -#endif - #ifdef AFS_SUN5_ENV /** The 32 bit OS expects the members of this structure to be 32 bit @@ -1578,36 +1615,4 @@ struct afssysa { extern int Afs_syscall(struct afssysa *uap, rval_t *rvp); #endif /* AFS_SUN5_ENV */ -/* - * Various definitions for osi_sleep and its event hash table - * DFBSD has no osi_sleep, and HPUX has its own hack for this stuff - */ -#define AFS_EVHASHSIZE 128 /* size of afs_evhasht, must be power of 2 */ - -typedef struct afs_event { - struct afs_event *next; /* next in hash chain */ - char *event; /* lwp event: an address */ - int refcount; /* Is it in use? */ - int seq; /* Sequence number: this is incremented - * by wakeup calls; wait will not return until - * it changes */ -#if defined(AFS_AIX_ENV) - tid_t cond; -#elif defined(AFS_DARWIN_ENV) -# ifdef AFS_DARWIN80_ENV - lck_mtx_t *lck; - thread_t owner; -# endif - /* no cond member */ -#elif defined(AFS_FBSD_ENV) || defined(AFS_OBSD_ENV) - int cond; /* "all this gluck should probably be replaced by CVs" */ -#elif defined(AFS_LINUX_ENV) - wait_queue_head_t cond; -#elif defined(AFS_NBSD_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) - kcondvar_t cond; /* Currently associated condition variable */ -#endif -} afs_event_t; - -extern afs_event_t *afs_evhasht[AFS_EVHASHSIZE]; /* Hash table for events */ - #endif /* _AFS_H_ */