blob: d45fb37887bc7ec596ad569dd05b583df496220e [file] [log] [blame]
Jeff Mahoney12fa8ec2008-05-02 15:03:58 -04001#ifndef _COMPAT_H_
2#define _COMPAT_H_
3
David Woodhouse2db04962008-08-07 11:19:43 -04004#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,26)
5#define trylock_page(page) (!TestSetPageLocked(page))
6#endif
Jeff Mahoney12fa8ec2008-05-02 15:03:58 -04007
Balaji Raobe6e8dc2008-07-21 02:01:56 +05308#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)
9static inline struct dentry *d_obtain_alias(struct inode *inode)
10{
11 struct dentry *d;
12
13 if (!inode)
14 return NULL;
15 if (IS_ERR(inode))
16 return ERR_CAST(inode);
17
18 d = d_alloc_anon(inode);
19 if (!d)
20 iput(inode);
21 return d;
22}
23#endif
24
Jeff Mahoney12fa8ec2008-05-02 15:03:58 -040025/*
26 * Even if AppArmor isn't enabled, it still has different prototypes.
27 * Add more distro/version pairs here to declare which has AppArmor applied.
28 */
29#if defined(CONFIG_SUSE_KERNEL)
30# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
31# define REMOVE_SUID_PATH 1
32# endif
33#endif
34
35/*
36 * catch any other distros that have patched in apparmor. This isn't
37 * 100% reliable because it won't catch people that hand compile their
38 * own distro kernels without apparmor compiled in. But, it is better
39 * than nothing.
40 */
41#ifdef CONFIG_SECURITY_APPARMOR
42# define REMOVE_SUID_PATH 1
43#endif
44
45#endif /* _COMPAT_H_ */