linux-change-dentry-cleanup-20050619
[openafs.git] / src / afs / LINUX / osi_machdep.h
index 278e56a..7d13d64 100644 (file)
 #define SIG_UNLOCK(X) spin_unlock_irq(&X->sig->siglock)
 #endif
 
+#if defined (STRUCT_TASK_STRUCT_HAS_RLIM)
+#define TASK_STRUCT_RLIM rlim
+#elif defined (STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM)
+#define TASK_STRUCT_RLIM signal->rlim
+#else
+#error Not sure what to do about rlim (should be in the Linux task struct somewhere....)
+#endif
+
 
 #define afs_hz HZ
 #include "h/sched.h"
 #ifdef AFS_LINUX_64BIT_KERNEL
 #define osi_GetTime(V)                                 \
     do {                                               \
-       struct timeval tv;                              \
-       do_gettimeofday(&tv);                           \
-       (V)->tv_sec = (afs_int32)tv.tv_sec;             \
-       (V)->tv_usec = (afs_int32)tv.tv_usec;           \
+       struct timeval __afs_tv;                              \
+       do_gettimeofday(&__afs_tv);                           \
+       (V)->tv_sec = (afs_int32)__afs_tv.tv_sec;             \
+       (V)->tv_usec = (afs_int32)__afs_tv.tv_usec;           \
     } while (0)
 #else
 #define osi_GetTime(V) do_gettimeofday((V))
@@ -74,7 +82,7 @@
 #define VN_HOLD(V) ((vnode_t *) V)->i_count++
 #endif
 
-#if defined(AFS_LINUX26_ENV)
+#if defined(AFS_LINUX24_ENV)
 #define VN_RELE(V) iput((struct inode *) V)
 #else
 #define VN_RELE(V) osi_iput((struct inode *) V)
@@ -103,6 +111,8 @@ extern struct vnodeops afs_file_iops, afs_dir_iops, afs_symlink_iops;
 /* We often need to pretend we're in user space to get memory transfers
  * right for the kernel calls we use.
  */
+#include <asm/uaccess.h>
+
 #ifdef KERNEL_SPACE_DECL
 #undef KERNEL_SPACE_DECL
 #undef TO_USER_SPACE
@@ -112,14 +122,16 @@ extern struct vnodeops afs_file_iops, afs_dir_iops, afs_symlink_iops;
 #define TO_USER_SPACE() { _fs_space_decl = get_fs(); set_fs(get_ds()); }
 #define TO_KERNEL_SPACE() set_fs(_fs_space_decl)
 
-/* Backwards compatibilty macros - copyin/copyout are redone because macro
- * inside parentheses is not evalutated.
- */
-#define memcpy_fromfs copy_from_user
-#define memcpy_tofs copy_to_user
-#define copyin(F, T, C)  (copy_from_user ((char*)(T), (char*)(F), (C)), 0)
-#define copyinstr(F, T, C, L) (copyin(F, T, C), *(L)=strlen(T), 0)
-#define copyout(F, T, C) (copy_to_user ((char*)(T), (char*)(F), (C)), 0)
+#define copyin(F, T, C)  (copy_from_user ((char*)(T), (char*)(F), (C)) > 0 ? EFAULT : 0)
+static inline long copyinstr(char *from, char *to, int count, int *length) {
+    long tmp;
+    tmp = strncpy_from_user(to, from, count);
+    if (tmp < 0)
+            return EFAULT;
+    *length = tmp;
+    return 0;
+}
+#define copyout(F, T, C) (copy_to_user ((char*)(T), (char*)(F), (C)) > 0 ? EFAULT : 0)
 
 /* kernel print statements */
 #define printf printk
@@ -133,11 +145,7 @@ extern struct vnodeops afs_file_iops, afs_dir_iops, afs_symlink_iops;
 
 /* cred struct */
 typedef struct cred {          /* maps to task field: */
-#if (CPU == sparc64)
-    long cr_ref;
-#else
     int cr_ref;
-#endif
     uid_t cr_uid;              /* euid */
     uid_t cr_ruid;             /* uid */
     gid_t cr_gid;              /* egid */
@@ -148,6 +156,7 @@ typedef struct cred {               /* maps to task field: */
     gid_t cr_groups[NGROUPS];  /* 32 groups - empty set to NOGROUP */
     int cr_ngroups;
 #endif
+    struct cred *cr_next;
 } cred_t;
 #define AFS_UCRED cred
 #define AFS_PROC struct task_struct
@@ -174,6 +183,15 @@ typedef struct uio {
 /* Get/set the inode in the osifile struct. */
 #define FILE_INODE(F) (F)->f_dentry->d_inode
 
+#ifdef AFS_LINUX24_ENV
+#define OSIFILE_INODE(a) FILE_INODE((a)->filp)
+#else
+#define OSIFILE_INODE(a) FILE_INODE(&(a)->file)
+#endif
+
+#if defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV)
+#define NEED_IOCTL32
+#endif
 
 /* page offset is obtained and stored here during module initialization 
  * We need a variable to do this because, the PAGE_OFFSET macro defined in
@@ -185,7 +203,7 @@ extern unsigned long afs_linux_page_offset;
 /* function to help with the page offset stuff */
 #define afs_linux_page_address(page) (afs_linux_page_offset + PAGE_SIZE * (page - mem_map))
 
-#if defined(__KERNEL__) && defined(CONFIG_SMP)
+#if defined(__KERNEL__)
 #include "../h/sched.h"
 #include "linux/wait.h"
 
@@ -217,10 +235,6 @@ do { \
 #define AFS_GUNLOCK()
 #define ISAFS_GLOCK() 1
 #define AFS_ASSERT_GLOCK()
-#define AFS_ASSERT_RXGLOCK()
 #endif
 
-#define AFS_RXGLOCK()
-#define AFS_RXGUNLOCK()
-#define ISAFS_RXGLOCK() 1
 #endif /* OSI_MACHDEP_H_ */