Blame view

include/ext4fs.h 5.04 KB
a1596438a   Uma Shankar   ext4fs ls load su...
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
28
29
  /*
   * (C) Copyright 2011 - 2012 Samsung Electronics
   * EXT4 filesystem implementation in Uboot by
   * Uma Shankar <uma.shankar@samsung.com>
   * Manjunatha C Achar <a.manjunatha@samsung.com>
   *
   * Ext4 Extent data structures are taken from  original ext4 fs code
   * as found in the linux kernel.
   *
   * Copyright (c) 2003-2006, Cluster File Systems, Inc, info@clusterfs.com
   * Written by Alex Tomas <alex@clusterfs.com>
   *
   * This program is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as
   * published by the Free Software Foundation.
   *
   * This program is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   */
  
  #ifndef __EXT4__
  #define __EXT4__
  #include <ext_common.h>
10a7a1b8b   Stefan Brüns   ext4: Avoid corru...
30
  #define EXT4_INDEX_FL		0x00001000 /* Inode uses hash tree index */
a1596438a   Uma Shankar   ext4fs ls load su...
31
32
33
  #define EXT4_EXTENTS_FL		0x00080000 /* Inode uses extents */
  #define EXT4_EXT_MAGIC			0xf30a
  #define EXT4_FEATURE_RO_COMPAT_GDT_CSUM	0x0010
2e7365518   Sébastien Szymanski   fs: ext4: do not ...
34
  #define EXT4_FEATURE_RO_COMPAT_METADATA_CSUM 0x0400
a1596438a   Uma Shankar   ext4fs ls load su...
35
  #define EXT4_FEATURE_INCOMPAT_EXTENTS	0x0040
6f94ab665   Tom Rini   ext4: Refuse to m...
36
  #define EXT4_FEATURE_INCOMPAT_64BIT	0x0080
a1596438a   Uma Shankar   ext4fs ls load su...
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
  #define EXT4_INDIRECT_BLOCKS		12
  
  #define EXT4_BG_INODE_UNINIT		0x0001
  #define EXT4_BG_BLOCK_UNINIT		0x0002
  #define EXT4_BG_INODE_ZEROED		0x0004
  
  /*
   * ext4_inode has i_block array (60 bytes total).
   * The first 12 bytes store ext4_extent_header;
   * the remainder stores an array of ext4_extent.
   */
  
  /*
   * This is the extent on-disk structure.
   * It's used at the bottom of the tree.
   */
  struct ext4_extent {
  	__le32	ee_block;	/* first logical block extent covers */
  	__le16	ee_len;		/* number of blocks covered by extent */
  	__le16	ee_start_hi;	/* high 16 bits of physical block */
  	__le32	ee_start_lo;	/* low 32 bits of physical block */
  };
  
  /*
   * This is index on-disk structure.
   * It's used at all the levels except the bottom.
   */
  struct ext4_extent_idx {
  	__le32	ei_block;	/* index covers logical blocks from 'block' */
  	__le32	ei_leaf_lo;	/* pointer to the physical block of the next *
  				 * level. leaf or next index could be there */
  	__le16	ei_leaf_hi;	/* high 16 bits of physical block */
  	__u16	ei_unused;
  };
  
  /* Each block (leaves and indexes), even inode-stored has header. */
  struct ext4_extent_header {
  	__le16	eh_magic;	/* probably will support different formats */
  	__le16	eh_entries;	/* number of valid entries */
  	__le16	eh_max;		/* capacity of store in entries */
  	__le16	eh_depth;	/* has tree real underlying blocks? */
  	__le32	eh_generation;	/* generation of the tree */
  };
  
  struct ext_filesystem {
  	/* Total Sector of partition */
  	uint64_t total_sect;
  	/* Block size  of partition */
  	uint32_t blksz;
  	/* Inode size of partition */
  	uint32_t inodesz;
  	/* Sectors per Block */
  	uint32_t sect_perblk;
fc214ef90   Stefan Brüns   ext4: determine g...
90
91
  	/* Group Descriptor size */
  	uint16_t gdsize;
a1596438a   Uma Shankar   ext4fs ls load su...
92
93
94
95
96
97
98
99
100
  	/* Group Descriptor Block Number */
  	uint32_t gdtable_blkno;
  	/* Total block groups of partition */
  	uint32_t no_blkgrp;
  	/* No of blocks required for bgdtable */
  	uint32_t no_blk_pergdt;
  	/* Superblock */
  	struct ext2_sblock *sb;
  	/* Block group descritpor table */
a1596438a   Uma Shankar   ext4fs ls load su...
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
  	char *gdtable;
  
  	/* Block Bitmap Related */
  	unsigned char **blk_bmaps;
  	long int curr_blkno;
  	uint16_t first_pass_bbmap;
  
  	/* Inode Bitmap Related */
  	unsigned char **inode_bmaps;
  	int curr_inode_no;
  	uint16_t first_pass_ibmap;
  
  	/* Journal Related */
  
  	/* Block Device Descriptor */
4101f6879   Simon Glass   dm: Drop the bloc...
116
  	struct blk_desc *dev_desc;
a1596438a   Uma Shankar   ext4fs ls load su...
117
  };
a1596438a   Uma Shankar   ext4fs ls load su...
118
119
  extern struct ext2_data *ext4fs_root;
  extern struct ext2fs_node *ext4fs_file;
03e2ecf6b   Stephen Warren   fs: separate CONF...
120
  #if defined(CONFIG_EXT4_WRITE)
ed34f34db   Uma Shankar   ext4fs write support
121
122
123
124
125
126
  extern struct ext2_inode *g_parent_inode;
  extern int gd_index;
  extern int gindex;
  
  int ext4fs_init(void);
  void ext4fs_deinit(void);
76a29519f   Stefan Brüns   ext4: fix possibl...
127
  int ext4fs_filename_unlink(char *filename);
ed34f34db   Uma Shankar   ext4fs write support
128
  int ext4fs_write(const char *fname, unsigned char *buffer,
9f12cd0e0   Suriyan Ramasami   ext4: Prepare API...
129
130
131
  		 unsigned long sizebytes);
  int ext4_write_file(const char *filename, void *buf, loff_t offset, loff_t len,
  		    loff_t *actwrite);
ed34f34db   Uma Shankar   ext4fs write support
132
  #endif
a1596438a   Uma Shankar   ext4fs ls load su...
133
  struct ext_filesystem *get_fs(void);
9f12cd0e0   Suriyan Ramasami   ext4: Prepare API...
134
  int ext4fs_open(const char *filename, loff_t *len);
66a47ff2d   Stefan Brüns   ext4: Allow readi...
135
  int ext4fs_read(char *buf, loff_t offset, loff_t len, loff_t *actread);
a1596438a   Uma Shankar   ext4fs ls load su...
136
137
  int ext4fs_mount(unsigned part_length);
  void ext4fs_close(void);
8b454eeee   Łukasz Majewski   fs:ext4:write:fix...
138
  void ext4fs_reinit_global(void);
a1596438a   Uma Shankar   ext4fs ls load su...
139
  int ext4fs_ls(const char *dirname);
55af5c931   Stephen Warren   ext4: implement e...
140
  int ext4fs_exists(const char *filename);
d455d8789   Suriyan Ramasami   fs: API changes e...
141
  int ext4fs_size(const char *filename, loff_t *size);
a1596438a   Uma Shankar   ext4fs ls load su...
142
  void ext4fs_free_node(struct ext2fs_node *node, struct ext2fs_node *currroot);
04735e9c5   Frederic Leroy   Fix ext2/ext4 fil...
143
  int ext4fs_devread(lbaint_t sector, int byte_offset, int byte_len, char *buf);
4101f6879   Simon Glass   dm: Drop the bloc...
144
  void ext4fs_set_blk_dev(struct blk_desc *rbdd, disk_partition_t *info);
a1596438a   Uma Shankar   ext4fs ls load su...
145
  long int read_allocated_block(struct ext2_inode *inode, int fileblock);
4101f6879   Simon Glass   dm: Drop the bloc...
146
  int ext4fs_probe(struct blk_desc *fs_dev_desc,
e6d524153   Simon Glass   fs: Move ls and r...
147
  		 disk_partition_t *fs_partition);
d455d8789   Suriyan Ramasami   fs: API changes e...
148
149
  int ext4_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
  		   loff_t *actread);
50ce4c07d   Egbert Eich   fs/ext4: Support ...
150
  int ext4_read_superblock(char *buffer);
59e890ef7   Christian Gmeiner   fs: make it possi...
151
  int ext4fs_uuid(char *uuid_str);
a1596438a   Uma Shankar   ext4fs ls load su...
152
  #endif