OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [redboot/] [current/] [include/] [fs/] [e2fs.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      e2fs.h
4
//
5
//      Second extended filesystem defines.
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    msalter
43
// Contributors: msalter
44
// Date:         2001-06-25
45
// Purpose:      
46
// Description:  
47
//              
48
// This code is part of RedBoot (tm).
49
//
50
//####DESCRIPTIONEND####
51
//
52
//==========================================================================
53
 
54
#ifndef CYGONCE_REDBOOT_E2FS_H
55
#define CYGONCE_REDBOOT_E2FS_H
56
 
57
//
58
// Structure of the super block
59
//
60
struct e2fs_super_block {
61
    cyg_uint32  inodes_count;
62
    cyg_uint32  blocks_count;
63
    cyg_uint32  r_blocks_count;
64
    cyg_uint32  free_blocks_count;
65
    cyg_uint32  free_inodes_count;
66
    cyg_uint32  first_data_block;
67
    cyg_uint32  log_block_size;
68
    cyg_int32   log_frag_size;
69
    cyg_uint32  blocks_per_group;
70
    cyg_uint32  frags_per_group;
71
    cyg_uint32  inodes_per_group;
72
    cyg_uint32  mtime;
73
    cyg_uint32  wtime;
74
    cyg_uint16  mnt_count;
75
    cyg_int16   max_mnt_count;
76
    cyg_uint16  magic;
77
    cyg_uint16  state;
78
    cyg_uint16  errors;
79
    cyg_uint16  minor_rev_level;
80
    cyg_uint32  lastcheck;
81
    cyg_uint32  checkinterval;
82
    cyg_uint32  creator_os;
83
    cyg_uint32  rev_level;
84
    cyg_uint16  def_resuid;
85
    cyg_uint16  def_resgid;
86
};
87
 
88
#define E2FS_PRE_02B_MAGIC      0xEF51
89
#define E2FS_SUPER_MAGIC        0xEF53
90
 
91
#define E2FS_PTRS_PER_BLOCK(e)   ((e)->blocksize / sizeof(cyg_uint32))
92
 
93
#define E2FS_BLOCK_SIZE(s)        (E2FS_MIN_BLOCK_SIZE << SWAB_LE32((s)->log_block_size))
94
#define E2FS_ADDR_PER_BLOCK(s)    (E2FS_BLOCK_SIZE(s) / sizeof(unsigned int))
95
#define E2FS_BLOCK_SIZE_BITS(s)   (SWAB_LE32((s)->log_block_size) + 10)
96
 
97
#define E2FS_NR_DIR_BLOCKS      12
98
 
99
#define E2FS_IND_BLOCK          E2FS_NR_DIR_BLOCKS
100
#define E2FS_DIND_BLOCK         (E2FS_IND_BLOCK + 1)
101
#define E2FS_TIND_BLOCK         (E2FS_DIND_BLOCK + 1)
102
 
103
#define E2FS_N_BLOCKS           (E2FS_TIND_BLOCK + 1)
104
 
105
 
106
// Structure of an inode on the disk
107
//
108
typedef struct e2fs_inode {
109
    cyg_uint16   mode;
110
    cyg_uint16   uid;
111
    cyg_uint32   size;
112
    cyg_uint32   atime;
113
    cyg_uint32   ctime;
114
    cyg_uint32   mtime;
115
    cyg_uint32   dtime;
116
    cyg_uint16   gid;
117
    cyg_uint16   links_count;
118
    cyg_uint32   blocks;
119
    cyg_uint32   flags;
120
    cyg_uint32   reserved1;
121
    cyg_uint32   block[E2FS_N_BLOCKS];
122
    cyg_uint32   version;
123
    cyg_uint32   file_acl;
124
    cyg_uint32   dir_acl;
125
    cyg_uint32   faddr;
126
    cyg_uint8    frag;
127
    cyg_uint8    fsize;
128
    cyg_uint16   pad1;
129
    cyg_uint32   reserved2[2];
130
} e2fs_inode_t;
131
 
132
 
133
#define E2FS_INODES_PER_BLOCK(e)  ((e)->blocksize / sizeof (struct e2fs_inode))
134
 
135
#define E2FS_MIN_BLOCK_SIZE       1024
136
#define E2FS_MAX_BLOCK_SIZE       4096
137
 
138
// Special inode numbers
139
//
140
#define E2FS_BAD_INO             1
141
#define E2FS_ROOT_INO            2
142
 
143
typedef struct e2fs_dir_entry {
144
    cyg_uint32 inode;
145
    cyg_uint16 reclen;
146
    cyg_uint8  namelen;
147
    cyg_uint8  filetype;
148
    char       name[2];
149
} e2fs_dir_entry_t;
150
 
151
#define E2FS_FTYPE_UNKNOWN  0
152
#define E2FS_FTYPE_REG_FILE 1
153
#define E2FS_FTYPE_DIR      2
154
#define E2FS_FTYPE_CHRDEV   3
155
#define E2FS_FTYPE_BLKDEV   4
156
#define E2FS_FTYPE_FIFO     5
157
#define E2FS_FTYPE_SOCK     6
158
#define E2FS_FTYPE_SYMLINK  7
159
 
160
typedef struct e2fs_group
161
{
162
    cyg_uint32 block_bitmap;       // blocks bitmap block
163
    cyg_uint32 inode_bitmap;       // inodes bitmap block
164
    cyg_uint32 inode_table;        // inodes table block
165
    cyg_uint16 free_blocks_count;
166
    cyg_uint16 free_inodes_count;
167
    cyg_uint16 used_dirs_count;
168
    cyg_uint16 pad;
169
    cyg_uint32 reserved[3];
170
} e2fs_group_t;
171
 
172
#define E2FS_BLOCKS_PER_GROUP(s)  (SWAB_LE32((s)->blocks_per_group))
173
#define E2FS_INODES_PER_GROUP(s)  (SWAB_LE32((s)->inodes_per_group))
174
 
175
#define E2FS_GDESC_PER_BLOCK(e)   ((e)->blocksize / sizeof (struct e2fs_e2fs_group_desc))
176
#define E2FS_GDESC_PER_SECTOR     (SECTOR_SIZE/sizeof(e2fs_group_t))
177
#define E2FS_GDESC_CACHE_SIZE     (E2FS_GDESC_PER_SECTOR * 1)
178
#define E2FS_GDESC_PER_SECTOR     (SECTOR_SIZE/sizeof(e2fs_group_t))
179
 
180
typedef struct e2fs_desc {
181
    partition_t  *part;                 // partition holding this filesystem
182
    cyg_uint32   blocksize;             // fs blocksize
183
    cyg_uint32   ngroups;               // number of groups in fs
184
    cyg_uint32   blocks_per_group;
185
    cyg_uint32   inodes_per_group;
186
    cyg_uint32   gdesc_block;           // block nr of group descriptors
187
    cyg_int32    gdesc_first;           // which gdesc is first in cache
188
    e2fs_group_t gdesc_cache[E2FS_GDESC_CACHE_SIZE];
189
    cyg_uint32   nr_ind_blocks;
190
    cyg_uint32   nr_dind_blocks;
191
    cyg_uint32   nr_tind_blocks;
192
} e2fs_desc_t;
193
 
194
#define E2FS_BLOCK_TO_SECTOR(e,b)  ((b) * ((e)->blocksize / SECTOR_SIZE))
195
 
196
extern fs_funs_t redboot_e2fs_funs;
197
 
198
#endif  // CYGONCE_REDBOOT_E2FS_H

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.