DEVEL15-linux-2624-20071123
[openafs.git] / src / afs / LINUX / osi_machdep.h
index fd28337..d398c7e 100644 (file)
 #ifndef OSI_MACHDEP_H_
 #define OSI_MACHDEP_H_
 
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+#define AFS_LINUX26_ONEGROUP_ENV 1
+#endif
+
 /* Only needed for xdr.h in glibc 2.1.x */
 #ifndef quad_t
 #define quad_t __quad_t
 
 #undef getuerror
 
+#ifdef STRUCT_TASK_STRUCT_HAS_TGID
+#define getpid() current->tgid
+#ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
+#define getppid() current->real_parent->tgid
+#elif defined(STRUCT_TASK_STRUCT_HAS_PARENT)
+#define getppid() current->parent->tgid
+#else
+#define getppid() current->p_opptr->tgid
+#endif
+#else /* !STRUCT_TASK_STRUCT_HAS_TGID */
 #define getpid() current->pid
 #ifdef STRUCT_TASK_STRUCT_HAS_REAL_PARENT
 #define getppid() current->real_parent->pid
+#elif defined(STRUCT_TASK_STRUCT_HAS_PARENT)
+#define getppid() current->parent->pid
 #else
 #define getppid() current->p_opptr->pid
 #endif
+#endif /* STRUCT_TASK_STRUCT_HAS_TGID */
 
 #ifdef RECALC_SIGPENDING_TAKES_VOID
 #define RECALC_SIGPENDING(X) recalc_sigpending()
 
 #define afs_hz HZ
 #include "h/sched.h"
+#if defined(HAVE_CURRENT_KERNEL_TIME)
+static inline time_t osi_Time(void) { 
+    struct timespec xtime;
+    xtime = current_kernel_time();
+    return xtime.tv_sec;
+}
+#else
 #define osi_Time() (xtime.tv_sec)
+#endif
+
+
+
 #ifdef AFS_LINUX_64BIT_KERNEL
 #define osi_GetTime(V)                                 \
     do {                                               \
@@ -121,7 +150,6 @@ static inline long copyinstr(char *from, char *to, int count, int *length) {
 #define uprintf printk
 
 
-#define PAGESIZE PAGE_SIZE
 #ifndef NGROUPS
 #define NGROUPS NGROUPS_SMALL
 #endif
@@ -187,15 +215,22 @@ extern unsigned long afs_linux_page_offset;
 #define afs_linux_page_address(page) (afs_linux_page_offset + PAGE_SIZE * (page - mem_map))
 
 #if defined(__KERNEL__)
-#include "../h/sched.h"
-#include "linux/wait.h"
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <linux/wait.h>
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
+extern struct mutex afs_global_lock;
+#else
 extern struct semaphore afs_global_lock;
+#define mutex_lock(lock) down(lock)
+#define mutex_unlock(lock) up(lock)
+#endif
 extern int afs_global_owner;
 
 #define AFS_GLOCK() \
 do { \
-        down(&afs_global_lock); \
+        mutex_lock(&afs_global_lock); \
         if (afs_global_owner) \
             osi_Panic("afs_global_lock already held by pid %d", \
                       afs_global_owner); \
@@ -209,10 +244,8 @@ do { \
     if (!ISAFS_GLOCK()) \
        osi_Panic("afs global lock not held at %s:%d", __FILE__, __LINE__); \
     afs_global_owner = 0; \
-    up(&afs_global_lock); \
+    mutex_unlock(&afs_global_lock); \
 } while (0)
-
-
 #else
 #define AFS_GLOCK()
 #define AFS_GUNLOCK()
@@ -220,4 +253,66 @@ do { \
 #define AFS_ASSERT_GLOCK()
 #endif
 
+#ifdef AFS_AMD64_LINUX20_ENV
+/* RHEL5 beta's kernel doesn't define these. They aren't gonna change, so... */
+
+#ifndef __NR_ia32_afs_syscall
+#define __NR_ia32_afs_syscall 137
+#endif
+#ifndef __NR_ia32_setgroups
+#define __NR_ia32_setgroups 81
+#endif
+#ifndef __NR_ia32_setgroups32
+#define __NR_ia32_setgroups32 206
+#endif
+#ifndef __NR_ia32_close
+#define __NR_ia32_close 6
+#endif
+#ifndef __NR_ia32_chdir
+#define __NR_ia32_chdir 12
+#endif
+#ifndef __NR_ia32_break
+#define __NR_ia32_break 17
+#endif
+#ifndef __NR_ia32_stty
+#define __NR_ia32_stty 31
+#endif
+#ifndef __NR_ia32_gtty
+#define __NR_ia32_gtty 32
+#endif
+#ifndef __NR_ia32_ftime
+#define __NR_ia32_ftime 35
+#endif
+#ifndef __NR_ia32_prof
+#define __NR_ia32_prof 44
+#endif
+#ifndef __NR_ia32_lock
+#define __NR_ia32_lock 53
+#endif
+#ifndef __NR_ia32_mpx
+#define __NR_ia32_mpx 56
+#endif
+#ifndef __NR_ia32_exit
+#define __NR_ia32_exit 1
+#endif
+#ifndef __NR_ia32_mount
+#define __NR_ia32_mount 21
+#endif
+#ifndef __NR_ia32_read
+#define __NR_ia32_read 3
+#endif
+#ifndef __NR_ia32_write
+#define __NR_ia32_write 4
+#endif
+#ifndef __NR_ia32_open
+#define __NR_ia32_open 5
+#endif
+#ifndef __NR_ia32_close
+#define __NR_ia32_close 6
+#endif
+#ifndef __NR_ia32_unlink
+#define __NR_ia32_unlink 10
+#endif
+#endif
+
 #endif /* OSI_MACHDEP_H_ */