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)  * befs.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2001-2002 Will Dyson <will_dyson@pobox.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 1999 Makoto Kato (m_kato@ga2.so-net.ne.jp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #ifndef _LINUX_BEFS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #define _LINUX_BEFS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include "befs_fs_types.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) /* used in debug.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #define BEFS_VERSION "0.9.3"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) typedef u64 befs_blocknr_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20)  * BeFS in memory structures
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) struct befs_mount_options {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 	kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 	kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 	int use_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	int use_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	int debug;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	char *iocharset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) struct befs_sb_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 	u32 magic1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u32 block_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	u32 block_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	int byte_order;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	befs_off_t num_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 	befs_off_t used_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	u32 inode_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 	u32 magic2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	/* Allocation group information */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	u32 blocks_per_ag;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	u32 ag_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	u32 num_ags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	/* State of the superblock */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	u32 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	/* Journal log entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	befs_block_run log_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	befs_off_t log_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	befs_off_t log_end;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	befs_inode_addr root_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 	befs_inode_addr indices;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 	u32 magic3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	struct befs_mount_options mount_opts;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct nls_table *nls;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) struct befs_inode_info {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	u32 i_flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	u32 i_type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	befs_inode_addr i_inode_num;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	befs_inode_addr i_parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	befs_inode_addr i_attribute;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		befs_data_stream ds;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		char symlink[BEFS_SYMLINK_LEN];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	} i_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	struct inode vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) enum befs_err {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 	BEFS_OK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 	BEFS_ERR,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	BEFS_BAD_INODE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	BEFS_BT_END,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	BEFS_BT_EMPTY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	BEFS_BT_MATCH,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 	BEFS_BT_OVERFLOW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	BEFS_BT_NOT_FOUND
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) /****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) /* debug.c */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) __printf(2, 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) void befs_error(const struct super_block *sb, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) __printf(2, 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) void befs_warning(const struct super_block *sb, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) __printf(2, 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) void befs_debug(const struct super_block *sb, const char *fmt, ...);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) void befs_dump_super_block(const struct super_block *sb, befs_super_block *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) void befs_dump_inode(const struct super_block *sb, befs_inode *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) void befs_dump_index_entry(const struct super_block *sb, befs_disk_btree_super *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) void befs_dump_index_node(const struct super_block *sb, befs_btree_nodehead *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) /****************************/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) /* Gets a pointer to the private portion of the super_block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * structure from the public part
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static inline struct befs_sb_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) BEFS_SB(const struct super_block *super)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	return (struct befs_sb_info *) super->s_fs_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline struct befs_inode_info *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) BEFS_I(const struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	return container_of(inode, struct befs_inode_info, vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline befs_blocknr_t
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) iaddr2blockno(struct super_block *sb, const befs_inode_addr *iaddr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	return ((iaddr->allocation_group << BEFS_SB(sb)->ag_shift) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		iaddr->start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) static inline befs_inode_addr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) blockno2iaddr(struct super_block *sb, befs_blocknr_t blockno)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	befs_inode_addr iaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	iaddr.allocation_group = blockno >> BEFS_SB(sb)->ag_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	iaddr.start =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	    blockno - (iaddr.allocation_group << BEFS_SB(sb)->ag_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	iaddr.len = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	return iaddr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) static inline unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) befs_iaddrs_per_block(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	return BEFS_SB(sb)->block_size / sizeof(befs_disk_inode_addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #include "endian.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) #endif				/* _LINUX_BEFS_H */