itree_v1.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #include <linux/buffer_head.h>
  2. #include <linux/slab.h>
  3. #include "minix.h"
  4. enum {DEPTH = 3, DIRECT = 7}; /* Only double indirect */
  5. typedef u16 block_t; /* 16 bit, host order */
  6. static inline unsigned long block_to_cpu(block_t n)
  7. {
  8. return n;
  9. }
  10. static inline block_t cpu_to_block(unsigned long n)
  11. {
  12. return n;
  13. }
  14. static inline block_t *i_data(struct inode *inode)
  15. {
  16. return (block_t *)minix_i(inode)->u.i1_data;
  17. }
  18. static int block_to_path(struct inode * inode, long block, int offsets[DEPTH])
  19. {
  20. int n = 0;
  21. if (block < 0) {
  22. printk("MINIX-fs: block_to_path: block %ld < 0 on dev %pg\n",
  23. block, inode->i_sb->s_bdev);
  24. } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
  25. if (printk_ratelimit())
  26. printk("MINIX-fs: block_to_path: "
  27. "block %ld too big on dev %pg\n",
  28. block, inode->i_sb->s_bdev);
  29. } else if (block < 7) {
  30. offsets[n++] = block;
  31. } else if ((block -= 7) < 512) {
  32. offsets[n++] = 7;
  33. offsets[n++] = block;
  34. } else {
  35. block -= 512;
  36. offsets[n++] = 8;
  37. offsets[n++] = block>>9;
  38. offsets[n++] = block & 511;
  39. }
  40. return n;
  41. }
  42. #include "itree_common.c"
  43. int V1_minix_get_block(struct inode * inode, long block,
  44. struct buffer_head *bh_result, int create)
  45. {
  46. return get_block(inode, block, bh_result, create);
  47. }
  48. void V1_minix_truncate(struct inode * inode)
  49. {
  50. truncate(inode);
  51. }
  52. unsigned V1_minix_blocks(loff_t size, struct super_block *sb)
  53. {
  54. return nblocks(size, sb);
  55. }