file_cache.c 961 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2013
  3. * Phillip Lougher <phillip@squashfs.org.uk>
  4. *
  5. * This work is licensed under the terms of the GNU GPL, version 2. See
  6. * the COPYING file in the top-level directory.
  7. */
  8. #include <linux/fs.h>
  9. #include <linux/vfs.h>
  10. #include <linux/kernel.h>
  11. #include <linux/slab.h>
  12. #include <linux/string.h>
  13. #include <linux/pagemap.h>
  14. #include <linux/mutex.h>
  15. #include "squashfs_fs.h"
  16. #include "squashfs_fs_sb.h"
  17. #include "squashfs_fs_i.h"
  18. #include "squashfs.h"
  19. /* Read separately compressed datablock and memcopy into page cache */
  20. int squashfs_readpage_block(struct page *page, u64 block, int bsize)
  21. {
  22. struct inode *i = page->mapping->host;
  23. struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
  24. block, bsize);
  25. int res = buffer->error;
  26. if (res)
  27. ERROR("Unable to read page, block %llx, size %x\n", block,
  28. bsize);
  29. else
  30. squashfs_copy_cache(page, buffer, buffer->length, 0);
  31. squashfs_cache_put(buffer);
  32. return res;
  33. }