OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/afs/UKERNEL/osi_machdep.h
00001 /*
00002  * Copyright 2000, International Business Machines Corporation and others.
00003  * All Rights Reserved.
00004  *
00005  * This software has been released under the terms of the IBM Public
00006  * License.  For details, see the LICENSE file in the top-level source
00007  * directory or online at http://www.openafs.org/dl/license10.html
00008  */
00009 
00010 /*
00011  * UKERNEL OSI header file. Extends afs_osi.h.
00012  *
00013  * afs_osi.h includes this file, which is the only way this file should
00014  * be included in a source file. This file can redefine macros declared in
00015  * afs_osi.h.
00016  */
00017 
00018 #ifndef _OSI_MACHDEP_H_
00019 #define _OSI_MACHDEP_H_
00020 
00021 #include "afs/sysincludes.h"
00022 
00023 #define MAX_OSI_PATH            1024
00024 #define MAX_OSI_FILES           1024
00025 #define MAX_OSI_LINKS           25
00026 #define OSI_WAITHASH_SIZE       128     /* must be power of two */
00027 #define MAX_HOSTADDR            32
00028 
00029 /* XXX
00030  *
00031  * UKERNEL cannot trivially make use of typedef for afs_ucred_t and
00032  * afs_proc_t, as in the present design, the types are already introduced
00033  * with incorrect reference, so fall back to preprocessor for now
00034  */
00035 
00036 #define afs_ucred_t struct usr_ucred
00037 #define afs_proc_t struct usr_proc
00038 
00039 #define AFS_KALLOC(A)           afs_osi_Alloc(A)
00040 
00041 /*
00042  * Time related macros
00043  */
00044 #define afs_hz      HZ
00045 #define osi_Time() (time(NULL))
00046 
00047 #undef gop_lookupname
00048 #define gop_lookupname(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),(compvpp))
00049 #undef gop_lookupname_user
00050 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),(compvpp))
00051 
00052 #define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
00053 
00054 #if 0
00055 #define afs_suser(x)        suser(x)
00056 #endif
00057 /*
00058  * Global lock support.
00059  */
00060 
00061 extern usr_thread_t afs_global_owner;
00062 extern usr_mutex_t afs_global_lock;
00063 
00064 #define ISAFS_GLOCK() (usr_thread_self() == afs_global_owner)
00065 
00066 #define AFS_GLOCK() \
00067     do { \
00068         usr_mutex_lock(&afs_global_lock); \
00069         afs_global_owner = usr_thread_self(); \
00070     } while(0)
00071 #define AFS_GUNLOCK() \
00072     do { \
00073         AFS_ASSERT_GLOCK(); \
00074         memset(&afs_global_owner, 0, sizeof(usr_thread_t)); \
00075         usr_mutex_unlock(&afs_global_lock); \
00076     } while(0)
00077 #define AFS_ASSERT_GLOCK() \
00078     do { if (!ISAFS_GLOCK()) { osi_Panic("afs global lock not held"); } } while(0)
00079 #define osi_GlockInit() \
00080     usr_mutex_init(&afs_global_lock, "afs_global_lock", MUTEX_DEFAULT, NULL)
00081 
00082 extern int afs_bufferpages;
00083 
00084 extern int afs_suser(void *credp);
00085 
00086 #define setuerror(erval) get_user_struct()->u_error = (erval)
00087 #define getuerror(erval) get_user_struct()->u_error
00088 #define osi_curcred()    get_user_struct()->u_cred
00089 
00090 #define osi_procname(procname, size) strncpy(procname, "(unknown)", size)
00091 #endif /* _OSI_MACHDEP_H_ */
 All Data Structures Files Functions Variables