オープンソース・ソフトウェアの開発とダウンロード

Subversion リポジトリの参照

Diff of /trunk/1.8.x/ccs-patch/security/ccsecurity/compat.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

trunk/1.6.x/ccs-patch/include/linux/ccs_compat.h revision 2219 by kumaneko, Tue Mar 3 06:30:38 2009 UTC trunk/1.7.x/ccs-patch/security/ccsecurity/compat.h revision 3109 by kumaneko, Fri Oct 16 05:02:23 2009 UTC
# Line 1  Line 1 
1  /*  /*
2   * include/linux/ccs_compat.h   * security/ccsecurity/compat.h
  *  
  * For compatibility for older kernels.  
3   *   *
4   * Copyright (C) 2005-2009  NTT DATA CORPORATION   * Copyright (C) 2005-2009  NTT DATA CORPORATION
5   *   *
6   * Version: 1.6.7-rc   2009/03/03   * Version: 1.7.1-pre   2009/10/16
7   *   *
8   * This file is applicable to both 2.4.30 and 2.6.11 and later.   * This file is applicable to both 2.4.30 and 2.6.11 and later.
9   * See README.ccs for ChangeLog.   * See README.ccs for ChangeLog.
# Line 66  Line 64 
64  #define mutex_lock(mutex) down(mutex)  #define mutex_lock(mutex) down(mutex)
65  #define mutex_unlock(mutex) up(mutex)  #define mutex_unlock(mutex) up(mutex)
66  #define mutex_lock_interruptible(mutex) down_interruptible(mutex)  #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
67    #define mutex_trylock(mutex) !down_trylock(mutex)
68  #define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname)  #define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname)
69  #endif  #endif
70    
# Line 76  Line 75 
75  #endif  #endif
76    
77  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
78  #define kzalloc(size, flags) ({                                         \  #define kzalloc(size, flags) ({                                 \
79                          void *ret = kmalloc((size), (flags));           \                          void *ret = kmalloc((size), (flags));   \
80                          if (ret)                                        \                          if (ret)                                \
81                                  memset(ret, 0, (size));                 \                                  memset(ret, 0, (size));         \
82                          ret; })                          ret; })
83  #endif  #endif
84    
# Line 92  Line 91 
91  #endif  #endif
92    
93  #ifndef rcu_dereference  #ifndef rcu_dereference
94  #define rcu_dereference(p)     ({ \  #define rcu_dereference(p)     ({                                       \
95                                  typeof(p) _________p1 = ACCESS_ONCE(p); \                          typeof(p) _________p1 = ACCESS_ONCE(p);         \
96                                  smp_read_barrier_depends(); /* see RCU */ \                          smp_read_barrier_depends(); /* see RCU */       \
97                                  (_________p1); \                          (_________p1);                                  \
98                                  })                  })
99  #endif  #endif
100    
101  #ifndef rcu_assign_pointer  #ifndef rcu_assign_pointer
102  #define rcu_assign_pointer(p, v) \  #define rcu_assign_pointer(p, v)                        \
103          ({ \          ({                                              \
104                  if (!__builtin_constant_p(v) || \                  if (!__builtin_constant_p(v) ||         \
105                      ((v) != NULL)) \                      ((v) != NULL))                      \
106                          smp_wmb(); /* see RCU */ \                          smp_wmb(); /* see RCU */        \
107                  (p) = (v); \                  (p) = (v);                              \
108          })          })
109  #endif  #endif
110    
111  #ifndef list_for_each_rcu  #ifndef list_for_each_rcu
112  #define list_for_each_rcu(pos, head) \  #define list_for_each_rcu(pos, head)                    \
113          for (pos = rcu_dereference((head)->next); \          for (pos = rcu_dereference((head)->next);       \
114                  prefetch(pos->next), pos != (head); \               prefetch(pos->next), pos != (head);        \
115                  pos = rcu_dereference(pos->next))               pos = rcu_dereference(pos->next))
116  #endif  #endif
117    
118  #ifndef list_for_each_entry_rcu  #ifndef list_for_each_entry_rcu
119  #define list_for_each_entry_rcu(pos, head, member) \  #define list_for_each_entry_rcu(pos, head, member)                      \
120          for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), \          for (pos = list_entry(rcu_dereference((head)->next), typeof(*pos), \
121                  member); \                                member);                                  \
122                  prefetch(pos->member.next), &pos->member != (head); \               prefetch(pos->member.next), &pos->member != (head);        \
123                  pos = list_entry(rcu_dereference(pos->member.next), \               pos = list_entry(rcu_dereference(pos->member.next),        \
124                  typeof(*pos), member))                                typeof(*pos), member))
125  #endif  #endif
126    
127  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
128  #define s_fs_info u.generic_sbp  static inline void __list_add_rcu(struct list_head *new,
129  #else                                    struct list_head *prev,
130  #include <linux/audit.h>                                    struct list_head *next)
131  #ifdef AUDIT_APPARMOR_AUDIT  {
132  /* AppArmor patch adds "struct vfsmount" to VFS helper functions. */          new->next = next;
133  #define HAVE_VFSMOUNT_IN_VFS_HELPER          new->prev = prev;
134  #endif          rcu_assign_pointer(prev->next, new);
135            next->prev = new;
136    }
137    
138    static inline void list_add_tail_rcu(struct list_head *new,
139                                         struct list_head *head)
140    {
141            __list_add_rcu(new, head->prev, head);
142    }
143    
144    static inline void list_add_rcu(struct list_head *new, struct list_head *head)
145    {
146            __list_add_rcu(new, head, head->next);
147    }
148    
149    #ifndef LIST_POISON2
150    #define LIST_POISON2  ((void *) 0x00200200)
151    #endif
152    
153    static inline void list_del_rcu(struct list_head *entry)
154    {
155            __list_del(entry->prev, entry->next);
156            entry->prev = LIST_POISON2;
157    }
158    #endif
159    
160    #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 30)
161    #undef ssleep
162    #define ssleep(secs) {                                          \
163                    set_current_state(TASK_UNINTERRUPTIBLE);        \
164                    schedule_timeout((HZ * secs) + 1);              \
165            }
166  #endif  #endif
167    
168  #if defined(RHEL_MAJOR) && RHEL_MAJOR == 5  #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
169  #define HAVE_NO_I_BLKSIZE_IN_INODE  #define s_fs_info u.generic_sbp
 #elif defined(AX_MAJOR) && AX_MAJOR == 3  
 #define HAVE_NO_I_BLKSIZE_IN_INODE  
170  #endif  #endif
171    
172  #ifndef list_for_each_entry_safe  #ifndef list_for_each_entry_safe
# Line 154  Line 182 
182  #define sk_protocol protocol  #define sk_protocol protocol
183  #define sk_type type  #define sk_type type
184  #define sk_receive_queue receive_queue  #define sk_receive_queue receive_queue
185    static inline struct socket *SOCKET_I(struct inode *inode)
186    {
187            return inode->i_sock ? &inode->u.socket_i : NULL;
188    }
189    #endif
190    
191    #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
192    #if defined(__LITTLE_ENDIAN)
193    #define HIPQUAD(addr)                           \
194            ((unsigned char *)&addr)[3],            \
195                    ((unsigned char *)&addr)[2],    \
196                    ((unsigned char *)&addr)[1],    \
197                    ((unsigned char *)&addr)[0]
198    #elif defined(__BIG_ENDIAN)
199    #define HIPQUAD NIPQUAD
200    #else
201    #error "Please fix asm/byteorder.h"
202    #endif /* __LITTLE_ENDIAN */
203    #endif
204    
205    #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
206    
207    struct path {
208            struct vfsmount *mnt;
209            struct dentry *dentry;
210    };
211    
212    #endif
213    
214    #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
215    
216    #include <linux/mount.h>
217    
218    static inline void path_get(struct path *path)
219    {
220            dget(path->dentry);
221            mntget(path->mnt);
222    }
223    
224    static inline void path_put(struct path *path)
225    {
226            dput(path->dentry);
227            mntput(path->mnt);
228    }
229    
230  #endif  #endif

Legend:
Removed from v.2219  
changed lines
  Added in v.3109

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26