file_cache.c 887 B

123456789101112131415161718192021222324252627282930313233343536
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (c) 2013
  4. * Phillip Lougher <phillip@squashfs.org.uk>
  5. */
  6. #include <linux/fs.h>
  7. #include <linux/vfs.h>
  8. #include <linux/kernel.h>
  9. #include <linux/slab.h>
  10. #include <linux/string.h>
  11. #include <linux/pagemap.h>
  12. #include <linux/mutex.h>
  13. #include "squashfs_fs.h"
  14. #include "squashfs_fs_sb.h"
  15. #include "squashfs_fs_i.h"
  16. #include "squashfs.h"
  17. /* Read separately compressed datablock and memcopy into page cache */
  18. int squashfs_readpage_block(struct page *page, u64 block, int bsize, int expected)
  19. {
  20. struct inode *i = page->mapping->host;
  21. struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
  22. block, bsize);
  23. int res = buffer->error;
  24. if (res)
  25. ERROR("Unable to read page, block %llx, size %x\n", block,
  26. bsize);
  27. else
  28. squashfs_copy_cache(page, buffer, expected, 0);
  29. squashfs_cache_put(buffer);
  30. return res;
  31. }