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. char b[BDEVNAME_SIZE];
  22. if (block < 0) {
  23. printk("MINIX-fs: block_to_path: block %ld < 0 on dev %s\n",
  24. block, bdevname(inode->i_sb->s_bdev, b));
  25. } else if (block >= (minix_sb(inode->i_sb)->s_max_size/BLOCK_SIZE)) {
  26. if (printk_ratelimit())
  27. printk("MINIX-fs: block_to_path: "
  28. "block %ld too big on dev %s\n",
  29. block, bdevname(inode->i_sb->s_bdev, b));
  30. } else if (block < 7) {
  31. offsets[n++] = block;
  32. } else if ((block -= 7) < 512) {
  33. offsets[n++] = 7;
  34. offsets[n++] = block;
  35. } else {
  36. block -= 512;
  37. offsets[n++] = 8;
  38. offsets[n++] = block>>9;
  39. offsets[n++] = block & 511;
  40. }
  41. return n;
  42. }
  43. #include "itree_common.c"
  44. int V1_minix_get_block(struct inode * inode, long block,
  45. struct buffer_head *bh_result, int create)
  46. {
  47. return get_block(inode, block, bh_result, create);
  48. }
  49. void V1_minix_truncate(struct inode * inode)
  50. {
  51. truncate(inode);
  52. }
  53. unsigned V1_minix_blocks(loff_t size, struct super_block *sb)
  54. {
  55. return nblocks(size, sb);
  56. }