Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags   |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * file.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Copyright (c) 1999 Al Smith
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Portions derived from work (c) 1995,1996 Christian Vogelgsang.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "efs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) int efs_get_block(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) 		  struct buffer_head *bh_result, int create)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	int error = -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 	long phys;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	if (create)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	if (iblock >= inode->i_blocks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 		 * i have no idea why this happens as often as it does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 		pr_warn("%s(): block %d >= %ld (filesize %ld)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 			__func__, block, inode->i_blocks, inode->i_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	phys = efs_map_block(inode, iblock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	if (phys)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		map_bh(bh_result, inode->i_sb, phys);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) int efs_bmap(struct inode *inode, efs_block_t block) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	if (block < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		pr_warn("%s(): block < 0\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	/* are we about to read past the end of a file ? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	if (!(block < inode->i_blocks)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 		 * i have no idea why this happens as often as it does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 		pr_warn("%s(): block %d >= %ld (filesize %ld)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 			__func__, block, inode->i_blocks, inode->i_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	return efs_map_block(inode, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }