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