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)  * QNX4 file system, Linux implementation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * Version : 0.2.1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Using parts of the xiafs filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9)  * History :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11)  * 28-05-1998 by Richard Frowijn : first release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)  * 20-06-1998 by Frank Denis : basic optimisations.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)  * 25-06-1998 by Frank Denis : qnx4_is_free, qnx4_set_bitmap, qnx4_bmap .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)  * 28-06-1998 by Frank Denis : qnx4_free_inode (to be fixed) .
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/buffer_head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/bitops.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "qnx4.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) unsigned long qnx4_count_free_blocks(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 	int total = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 	int total_free = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	int offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	int size = le32_to_cpu(qnx4_sb(sb)->BitMap->di_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	while (total < size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		int bytes = min(size - total, QNX4_BLOCK_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		if ((bh = sb_bread(sb, start + offset)) == NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 			printk(KERN_ERR "qnx4: I/O error in counting free blocks\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		total_free += bytes * BITS_PER_BYTE -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 				memweight(bh->b_data, bytes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		total += bytes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		offset++;
^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) 	return total_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }