file.c 1.2 KB

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