compat.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #ifndef _COMPAT_H_
  2. #define _COMPAT_H_
  3. #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,26)
  4. #define trylock_page(page) (!TestSetPageLocked(page))
  5. #endif
  6. #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,27)
  7. static inline struct dentry *d_obtain_alias(struct inode *inode)
  8. {
  9. struct dentry *d;
  10. if (!inode)
  11. return NULL;
  12. if (IS_ERR(inode))
  13. return ERR_CAST(inode);
  14. d = d_alloc_anon(inode);
  15. if (!d)
  16. iput(inode);
  17. return d;
  18. }
  19. #endif
  20. #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
  21. static inline void btrfs_drop_nlink(struct inode *inode)
  22. {
  23. inode->i_nlink--;
  24. }
  25. static inline void btrfs_inc_nlink(struct inode *inode)
  26. {
  27. inode->i_nlink++;
  28. }
  29. #else
  30. # define btrfs_drop_nlink(inode) drop_nlink(inode)
  31. # define btrfs_inc_nlink(inode) inc_nlink(inode)
  32. #endif
  33. /*
  34. * Even if AppArmor isn't enabled, it still has different prototypes.
  35. * Add more distro/version pairs here to declare which has AppArmor applied.
  36. */
  37. #if defined(CONFIG_SUSE_KERNEL)
  38. # if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,22)
  39. # define REMOVE_SUID_PATH 1
  40. # endif
  41. #endif
  42. /*
  43. * catch any other distros that have patched in apparmor. This isn't
  44. * 100% reliable because it won't catch people that hand compile their
  45. * own distro kernels without apparmor compiled in. But, it is better
  46. * than nothing.
  47. */
  48. #ifdef CONFIG_SECURITY_APPARMOR
  49. # define REMOVE_SUID_PATH 1
  50. #endif
  51. #endif /* _COMPAT_H_ */