file.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * file.c
  3. *
  4. * Copyright (c) 1999 Al Smith
  5. *
  6. * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
  7. */
  8. #include <linux/buffer_head.h>
  9. #include <linux/efs_fs.h>
  10. int efs_get_block(struct inode *inode, sector_t iblock,
  11. struct buffer_head *bh_result, int create)
  12. {
  13. int error = -EROFS;
  14. long phys;
  15. if (create)
  16. return error;
  17. if (iblock >= inode->i_blocks) {
  18. #ifdef DEBUG
  19. /*
  20. * i have no idea why this happens as often as it does
  21. */
  22. printk(KERN_WARNING "EFS: bmap(): block %d >= %ld (filesize %ld)\n",
  23. block,
  24. inode->i_blocks,
  25. inode->i_size);
  26. #endif
  27. return 0;
  28. }
  29. phys = efs_map_block(inode, iblock);
  30. if (phys)
  31. map_bh(bh_result, inode->i_sb, phys);
  32. return 0;
  33. }
  34. int efs_bmap(struct inode *inode, efs_block_t block) {
  35. if (block < 0) {
  36. printk(KERN_WARNING "EFS: bmap(): block < 0\n");
  37. return 0;
  38. }
  39. /* are we about to read past the end of a file ? */
  40. if (!(block < inode->i_blocks)) {
  41. #ifdef DEBUG
  42. /*
  43. * i have no idea why this happens as often as it does
  44. */
  45. printk(KERN_WARNING "EFS: bmap(): block %d >= %ld (filesize %ld)\n",
  46. block,
  47. inode->i_blocks,
  48. inode->i_size);
  49. #endif
  50. return 0;
  51. }
  52. return efs_map_block(inode, block);
  53. }