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)  * QNX6 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 : 1.0.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * History :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * 01-02-2012 by Kai Bankett (chaosman@ontika.net) : first release.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  * 16-02-2012 page map extension by Al Viro
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #ifdef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #undef pr_fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) typedef __u16 __bitwise __fs16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) typedef __u32 __bitwise __fs32;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) typedef __u64 __bitwise __fs64;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <linux/qnx6_fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) struct qnx6_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 	struct buffer_head	*sb_buf;	/* superblock buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 	struct qnx6_super_block	*sb;		/* our superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	int			s_blks_off;	/* blkoffset fs-startpoint */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	int			s_ptrbits;	/* indirect pointer bitfield */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	unsigned long		s_mount_opt;	/* all mount options */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	int			s_bytesex;	/* holds endianess info */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	struct inode *		inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct inode *		longfile;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) struct qnx6_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	__fs32			di_block_ptr[QNX6_NO_DIRECT_POINTERS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	__u8			di_filelevels;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	__u32			i_dir_start_lookup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	struct inode		vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) extern struct inode *qnx6_iget(struct super_block *sb, unsigned ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) extern struct dentry *qnx6_lookup(struct inode *dir, struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 					unsigned int flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) #ifdef CONFIG_QNX6FS_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) extern void qnx6_superblock_debug(struct qnx6_super_block *,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 						struct super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) extern const struct inode_operations qnx6_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) extern const struct file_operations qnx6_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) static inline struct qnx6_sb_info *QNX6_SB(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	return sb->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) static inline struct qnx6_inode_info *QNX6_I(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	return container_of(inode, struct qnx6_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) #define clear_opt(o, opt)		(o &= ~(QNX6_MOUNT_##opt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) #define set_opt(o, opt)			(o |= (QNX6_MOUNT_##opt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) #define test_opt(sb, opt)		(QNX6_SB(sb)->s_mount_opt & \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 					 QNX6_MOUNT_##opt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	BYTESEX_LE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	BYTESEX_BE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		return le64_to_cpu((__force __le64)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		return be64_to_cpu((__force __be64)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 		return (__force __fs64)cpu_to_le64(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 		return (__force __fs64)cpu_to_be64(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		return le32_to_cpu((__force __le32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 		return be32_to_cpu((__force __be32)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) static inline __fs32 cpu_to_fs32(struct qnx6_sb_info *sbi, __u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 	if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 		return (__force __fs32)cpu_to_le32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		return (__force __fs32)cpu_to_be32(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static inline __u16 fs16_to_cpu(struct qnx6_sb_info *sbi, __fs16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		return le16_to_cpu((__force __le16)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 		return be16_to_cpu((__force __be16)n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static inline __fs16 cpu_to_fs16(struct qnx6_sb_info *sbi, __u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	if (sbi->s_bytesex == BYTESEX_LE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		return (__force __fs16)cpu_to_le16(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 		return (__force __fs16)cpu_to_be16(n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) extern struct qnx6_super_block *qnx6_mmi_fill_super(struct super_block *s,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 						    int silent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static inline void qnx6_put_page(struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	kunmap(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	put_page(page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) extern unsigned qnx6_find_entry(int len, struct inode *dir, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 				struct page **res_page);