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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [redboot/] [v2_0/] [include/] [fs/] [e2fs.h] - Blame information for rev 631

Go to most recent revision | Details | Compare with Previous | View Log

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