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