2019-06-04 15:11:32 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2013-11-01 02:24:27 +07:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2013
|
|
|
|
* Phillip Lougher <phillip@squashfs.org.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/vfs.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/pagemap.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
|
|
|
|
#include "squashfs_fs.h"
|
|
|
|
#include "squashfs_fs_sb.h"
|
|
|
|
#include "squashfs_fs_i.h"
|
|
|
|
#include "squashfs.h"
|
|
|
|
|
|
|
|
/* Read separately compressed datablock and memcopy into page cache */
|
2018-08-02 22:45:15 +07:00
|
|
|
int squashfs_readpage_block(struct page *page, u64 block, int bsize, int expected)
|
2013-11-01 02:24:27 +07:00
|
|
|
{
|
|
|
|
struct inode *i = page->mapping->host;
|
|
|
|
struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
|
|
|
|
block, bsize);
|
|
|
|
int res = buffer->error;
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
ERROR("Unable to read page, block %llx, size %x\n", block,
|
|
|
|
bsize);
|
|
|
|
else
|
2018-08-02 22:45:15 +07:00
|
|
|
squashfs_copy_cache(page, buffer, expected, 0);
|
2013-11-01 02:24:27 +07:00
|
|
|
|
|
|
|
squashfs_cache_put(buffer);
|
|
|
|
return res;
|
|
|
|
}
|