1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#ifndef __EXT4__
28#define __EXT4__
29#include <ext_common.h>
30
31#define EXT4_EXTENTS_FL 0x00080000
32#define EXT4_EXT_MAGIC 0xf30a
33#define EXT4_FEATURE_RO_COMPAT_GDT_CSUM 0x0010
34#define EXT4_FEATURE_INCOMPAT_EXTENTS 0x0040
35#define EXT4_INDIRECT_BLOCKS 12
36
37#define EXT4_BG_INODE_UNINIT 0x0001
38#define EXT4_BG_BLOCK_UNINIT 0x0002
39#define EXT4_BG_INODE_ZEROED 0x0004
40
41
42
43
44
45
46
47
48
49
50
51struct ext4_extent {
52 __le32 ee_block;
53 __le16 ee_len;
54 __le16 ee_start_hi;
55 __le32 ee_start_lo;
56};
57
58
59
60
61
62struct ext4_extent_idx {
63 __le32 ei_block;
64 __le32 ei_leaf_lo;
65
66 __le16 ei_leaf_hi;
67 __u16 ei_unused;
68};
69
70
71struct ext4_extent_header {
72 __le16 eh_magic;
73 __le16 eh_entries;
74 __le16 eh_max;
75 __le16 eh_depth;
76 __le32 eh_generation;
77};
78
79struct ext_filesystem {
80
81 uint64_t total_sect;
82
83 uint32_t blksz;
84
85 uint32_t inodesz;
86
87 uint32_t sect_perblk;
88
89 uint32_t gdtable_blkno;
90
91 uint32_t no_blkgrp;
92
93 uint32_t no_blk_pergdt;
94
95 struct ext2_sblock *sb;
96
97 struct ext2_block_group *bgd;
98 char *gdtable;
99
100
101 unsigned char **blk_bmaps;
102 long int curr_blkno;
103 uint16_t first_pass_bbmap;
104
105
106 unsigned char **inode_bmaps;
107 int curr_inode_no;
108 uint16_t first_pass_ibmap;
109
110
111
112
113 block_dev_desc_t *dev_desc;
114};
115
116extern struct ext2_data *ext4fs_root;
117extern struct ext2fs_node *ext4fs_file;
118
119#if defined(CONFIG_EXT4_WRITE)
120extern struct ext2_inode *g_parent_inode;
121extern int gd_index;
122extern int gindex;
123
124int ext4fs_init(void);
125void ext4fs_deinit(void);
126int ext4fs_filename_check(char *filename);
127int ext4fs_write(const char *fname, unsigned char *buffer,
128 unsigned long sizebytes);
129#endif
130
131struct ext_filesystem *get_fs(void);
132int ext4fs_open(const char *filename);
133int ext4fs_read(char *buf, unsigned len);
134int ext4fs_mount(unsigned part_length);
135void ext4fs_close(void);
136int ext4fs_ls(const char *dirname);
137int ext4fs_exists(const char *filename);
138void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
139int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
140void ext4fs_set_blk_dev(block_dev_desc_t *rbdd, disk_partition_t *info);
141long int read_allocated_block(struct ext2_inode *inode, int fileblock);
142int ext4fs_probe(block_dev_desc_t *fs_dev_desc,
143 disk_partition_t *fs_partition);
144int ext4_read_file(const char *filename, void *buf, int offset, int len);
145int ext4_read_superblock(char *buffer);
146#endif
147