vxfs_kcompat.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef _VXFS_KCOMPAT_H
  2. #define _VXFS_KCOMPAT_H
  3. #include <linux/version.h>
  4. #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0))
  5. #include <linux/blkdev.h>
  6. typedef long sector_t;
  7. /* From include/linux/fs.h (Linux 2.5.2-pre3) */
  8. static inline struct buffer_head * sb_bread(struct super_block *sb, int block)
  9. {
  10. return bread(sb->s_dev, block, sb->s_blocksize);
  11. }
  12. /* Dito. */
  13. static inline void map_bh(struct buffer_head *bh, struct super_block *sb, int block)
  14. {
  15. bh->b_state |= 1 << BH_Mapped;
  16. bh->b_dev = sb->s_dev;
  17. bh->b_blocknr = block;
  18. }
  19. /* From fs/block_dev.c (Linux 2.5.2-pre2) */
  20. static inline int sb_set_blocksize(struct super_block *sb, int size)
  21. {
  22. int bits;
  23. if (set_blocksize(sb->s_dev, size) < 0)
  24. return 0;
  25. sb->s_blocksize = size;
  26. for (bits = 9, size >>= 9; size >>= 1; bits++)
  27. ;
  28. sb->s_blocksize_bits = bits;
  29. return sb->s_blocksize;
  30. }
  31. /* Dito. */
  32. static inline int sb_min_blocksize(struct super_block *sb, int size)
  33. {
  34. int minsize = get_hardsect_size(sb->s_dev);
  35. if (size < minsize)
  36. size = minsize;
  37. return sb_set_blocksize(sb, size);
  38. }
  39. #endif /* Kernel 2.4 */
  40. #endif /* _VXFS_KCOMPAT_H */