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

Subversion リポジトリの参照

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3582 - (hide annotations) (download) (as text)
Sat Apr 10 08:57:15 2010 UTC (14 years, 1 month ago) by kumaneko
Original Path: trunk/1.7.x/ccs-patch/security/ccsecurity/compat.h
File MIME type: text/x-chdr
File size: 5692 byte(s)
Fix invalid "struct nameidata" to "struct path" conversion macro.
1 kumaneko 2037 /*
2 kumaneko 2864 * security/ccsecurity/compat.h
3 kumaneko 2037 *
4 kumaneko 3502 * Copyright (C) 2005-2010 NTT DATA CORPORATION
5 kumaneko 2037 *
6 kumaneko 3561 * Version: 1.7.2 2010/04/01
7 kumaneko 2037 *
8     * This file is applicable to both 2.4.30 and 2.6.11 and later.
9     * See README.ccs for ChangeLog.
10     *
11     */
12    
13     #define false 0
14     #define true 1
15    
16     #ifndef __user
17     #define __user
18     #endif
19    
20     #ifndef current_uid
21     #define current_uid() (current->uid)
22     #endif
23     #ifndef current_gid
24     #define current_gid() (current->gid)
25     #endif
26     #ifndef current_euid
27     #define current_euid() (current->euid)
28     #endif
29     #ifndef current_egid
30     #define current_egid() (current->egid)
31     #endif
32     #ifndef current_suid
33     #define current_suid() (current->suid)
34     #endif
35     #ifndef current_sgid
36     #define current_sgid() (current->sgid)
37     #endif
38     #ifndef current_fsuid
39     #define current_fsuid() (current->fsuid)
40     #endif
41     #ifndef current_fsgid
42     #define current_fsgid() (current->fsgid)
43     #endif
44    
45     #ifndef WARN_ON
46     #define WARN_ON(x) do { } while (0)
47     #endif
48    
49     #ifndef DEFINE_SPINLOCK
50     #define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED
51     #endif
52    
53     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 19)
54     #define bool _Bool
55     #endif
56    
57     #ifndef KERN_CONT
58     #define KERN_CONT ""
59     #endif
60    
61     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
62     #define mutex semaphore
63     #define mutex_init(mutex) init_MUTEX(mutex)
64     #define mutex_unlock(mutex) up(mutex)
65 kumaneko 3547 #define mutex_lock(mutex) down(mutex)
66 kumaneko 2037 #define mutex_lock_interruptible(mutex) down_interruptible(mutex)
67 kumaneko 3512 #define mutex_trylock(mutex) (!down_trylock(mutex))
68 kumaneko 2037 #define DEFINE_MUTEX(mutexname) DECLARE_MUTEX(mutexname)
69     #endif
70    
71     #ifndef container_of
72     #define container_of(ptr, type, member) ({ \
73     const typeof(((type *)0)->member) *__mptr = (ptr); \
74     (type *)((char *)__mptr - offsetof(type, member)); })
75     #endif
76    
77     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 14)
78 kumaneko 2943 #define kzalloc(size, flags) ({ \
79     void *ret = kmalloc((size), (flags)); \
80     if (ret) \
81     memset(ret, 0, (size)); \
82 kumaneko 2037 ret; })
83     #endif
84    
85 kumaneko 2690 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 0)
86     #define smp_read_barrier_depends smp_rmb
87 kumaneko 2037 #endif
88    
89 kumaneko 2690 #ifndef ACCESS_ONCE
90     #define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
91     #endif
92    
93     #ifndef rcu_dereference
94 kumaneko 2943 #define rcu_dereference(p) ({ \
95     typeof(p) _________p1 = ACCESS_ONCE(p); \
96     smp_read_barrier_depends(); /* see RCU */ \
97     (_________p1); \
98     })
99 kumaneko 2690 #endif
100    
101     #ifndef rcu_assign_pointer
102 kumaneko 2943 #define rcu_assign_pointer(p, v) \
103     ({ \
104     if (!__builtin_constant_p(v) || \
105     ((v) != NULL)) \
106     smp_wmb(); /* see RCU */ \
107     (p) = (v); \
108 kumaneko 2690 })
109     #endif
110    
111 kumaneko 3535 #ifndef list_for_each_entry_rcu
112     #define list_for_each_entry_rcu(pos, head, member) \
113     for (pos = list_entry(rcu_dereference((head)->next), \
114     typeof(*pos), member); \
115     prefetch(pos->member.next), &pos->member != (head); \
116     pos = list_entry(rcu_dereference(pos->member.next), \
117     typeof(*pos), member))
118 kumaneko 2690 #endif
119    
120 kumaneko 3535 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
121     #undef list_for_each_entry_rcu
122     #define list_for_each_entry_rcu(pos, head, member) \
123     for (pos = list_entry(srcu_dereference((head)->next, &ccs_ss), \
124     typeof(*pos), member); \
125     prefetch(pos->member.next), &pos->member != (head); \
126     pos = list_entry(srcu_dereference(pos->member.next, &ccs_ss), \
127 kumaneko 2943 typeof(*pos), member))
128 kumaneko 2037 #endif
129    
130     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
131 kumaneko 2718 static inline void __list_add_rcu(struct list_head *new,
132     struct list_head *prev,
133     struct list_head *next)
134     {
135     new->next = next;
136     new->prev = prev;
137     rcu_assign_pointer(prev->next, new);
138     next->prev = new;
139     }
140    
141     static inline void list_add_tail_rcu(struct list_head *new,
142     struct list_head *head)
143     {
144     __list_add_rcu(new, head->prev, head);
145     }
146    
147     static inline void list_add_rcu(struct list_head *new, struct list_head *head)
148     {
149     __list_add_rcu(new, head, head->next);
150     }
151    
152     #ifndef LIST_POISON2
153     #define LIST_POISON2 ((void *) 0x00200200)
154     #endif
155    
156     static inline void list_del_rcu(struct list_head *entry)
157     {
158     __list_del(entry->prev, entry->next);
159     entry->prev = LIST_POISON2;
160     }
161     #endif
162    
163     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 30)
164 kumaneko 2720 #undef ssleep
165 kumaneko 2943 #define ssleep(secs) { \
166     set_current_state(TASK_UNINTERRUPTIBLE); \
167     schedule_timeout((HZ * secs) + 1); \
168     }
169 kumaneko 2718 #endif
170    
171     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
172 kumaneko 2037 #define s_fs_info u.generic_sbp
173     #endif
174    
175     #ifndef list_for_each_entry_safe
176     #define list_for_each_entry_safe(pos, n, head, member) \
177     for (pos = list_entry((head)->next, typeof(*pos), member), \
178     n = list_entry(pos->member.next, typeof(*pos), member); \
179     &pos->member != (head); \
180     pos = n, n = list_entry(n->member.next, typeof(*n), member))
181     #endif
182    
183     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 0)
184     #define sk_family family
185     #define sk_protocol protocol
186     #define sk_type type
187     #define sk_receive_queue receive_queue
188 kumaneko 2281 static inline struct socket *SOCKET_I(struct inode *inode)
189     {
190     return inode->i_sock ? &inode->u.socket_i : NULL;
191     }
192 kumaneko 2037 #endif
193 kumaneko 2402
194     #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
195     #if defined(__LITTLE_ENDIAN)
196 kumaneko 2943 #define HIPQUAD(addr) \
197     ((unsigned char *)&addr)[3], \
198     ((unsigned char *)&addr)[2], \
199     ((unsigned char *)&addr)[1], \
200     ((unsigned char *)&addr)[0]
201 kumaneko 2402 #elif defined(__BIG_ENDIAN)
202     #define HIPQUAD NIPQUAD
203     #else
204     #error "Please fix asm/byteorder.h"
205     #endif /* __LITTLE_ENDIAN */
206     #endif
207 kumaneko 2716
208 kumaneko 2911 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
209     struct path {
210 kumaneko 2943 struct vfsmount *mnt;
211     struct dentry *dentry;
212 kumaneko 2911 };
213     #endif
214    
215     #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 25)
216    
217     #include <linux/mount.h>
218    
219     static inline void path_get(struct path *path)
220     {
221     dget(path->dentry);
222     mntget(path->mnt);
223     }
224    
225     static inline void path_put(struct path *path)
226     {
227     dput(path->dentry);
228     mntput(path->mnt);
229     }
230    
231     #endif

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