Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (c) 2013
0004  * Phillip Lougher <phillip@squashfs.org.uk>
0005  */
0006 
0007 #include <linux/fs.h>
0008 #include <linux/vfs.h>
0009 #include <linux/kernel.h>
0010 #include <linux/slab.h>
0011 #include <linux/string.h>
0012 #include <linux/pagemap.h>
0013 #include <linux/mutex.h>
0014 
0015 #include "squashfs_fs.h"
0016 #include "squashfs_fs_sb.h"
0017 #include "squashfs_fs_i.h"
0018 #include "squashfs.h"
0019 
0020 /* Read separately compressed datablock and memcopy into page cache */
0021 int squashfs_readpage_block(struct page *page, u64 block, int bsize, int expected)
0022 {
0023     struct inode *i = page->mapping->host;
0024     struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
0025         block, bsize);
0026     int res = buffer->error;
0027 
0028     if (res)
0029         ERROR("Unable to read page, block %llx, size %x\n", block,
0030             bsize);
0031     else
0032         squashfs_copy_cache(page, buffer, expected, 0);
0033 
0034     squashfs_cache_put(buffer);
0035     return res;
0036 }