file.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 "efs.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. pr_warn("%s(): block %d >= %ld (filesize %ld)\n",
  23. __func__, block, inode->i_blocks, inode->i_size);
  24. #endif
  25. return 0;
  26. }
  27. phys = efs_map_block(inode, iblock);
  28. if (phys)
  29. map_bh(bh_result, inode->i_sb, phys);
  30. return 0;
  31. }
  32. int efs_bmap(struct inode *inode, efs_block_t block) {
  33. if (block < 0) {
  34. pr_warn("%s(): block < 0\n", __func__);
  35. return 0;
  36. }
  37. /* are we about to read past the end of a file ? */
  38. if (!(block < inode->i_blocks)) {
  39. #ifdef DEBUG
  40. /*
  41. * i have no idea why this happens as often as it does
  42. */
  43. pr_warn("%s(): block %d >= %ld (filesize %ld)\n",
  44. __func__, block, inode->i_blocks, inode->i_size);
  45. #endif
  46. return 0;
  47. }
  48. return efs_map_block(inode, block);
  49. }