Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/feature_tlsv12/sys/src/cmd/ext2srv/dat.h – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
typedef struct Xfs	Xfs;
2
typedef struct Xfile	Xfile;
3
typedef struct Iobuf	Iobuf;
4
typedef struct Ext2 Ext2;
5
 
6
typedef struct SuperBlock SuperBlock;
7
typedef struct GroupDesc GroupDesc;
8
typedef struct Inode Inode;
9
typedef struct DirEntry DirEntry;
10
 
11
#define SECTORSIZE	512
12
#define OFFSET_SUPER_BLOCK	1024
13
 
14
#define EXT2_SUPER_MAGIC	0xEF53
15
#define EXT2_MIN_BLOCK_SIZE  1024
16
#define EXT2_MAX_BLOCK_SIZE  4096
17
#define EXT2_ROOT_INODE	2
18
#define EXT2_FIRST_INO		11
19
#define EXT2_VALID_FS	0x0001
20
#define EXT2_ERROR_FS	0x0002
21
 
22
/*
23
 * Structure of the super block
24
 */
25
struct SuperBlock {
26
	uint	s_inodes_count;		/* Inodes count */
27
	uint	s_blocks_count;		/* Blocks count */
28
	uint	s_r_blocks_count;	/* Reserved blocks count */
29
	uint	s_free_blocks_count;	/* Free blocks count */
30
	uint	s_free_inodes_count;	/* Free inodes count */
31
	uint	s_first_data_block;	/* First Data Block */
32
	uint	s_log_block_size;	/* Block size */
33
	int	s_log_frag_size;	/* Fragment size */
34
	uint	s_blocks_per_group;	/* # Blocks per group */
35
	uint	s_frags_per_group;	/* # Fragments per group */
36
	uint	s_inodes_per_group;	/* # Inodes per group */
37
	uint	s_mtime;		/* Mount time */
38
	uint	s_wtime;		/* Write time */
39
	ushort	s_mnt_count;		/* Mount count */
40
	short	s_max_mnt_count;	/* Maximal mount count */
41
	ushort	s_magic;		/* Magic signature */
42
	ushort	s_state;		/* File system state */
43
	ushort	s_errors;		/* Behaviour when detecting errors */
44
	ushort	s_pad;
45
	uint	s_lastcheck;		/* time of last check */
46
	uint	s_checkinterval;	/* max. time between checks */
47
	uint	s_creator_os;		/* OS */
48
	uint	s_rev_level;		/* Revision level */
49
	ushort	s_def_resuid;		/* Default uid for reserved blocks */
50
	ushort	s_def_resgid;		/* Default gid for reserved blocks */
51
	uint	s_reserved[235];	/* Padding to the end of the block */
52
};
53
 
54
/*
55
 * Structure of a blocks group descriptor
56
 */
57
struct GroupDesc
58
{
59
	uint	bg_block_bitmap;		/* Blocks bitmap block */
60
	uint	bg_inode_bitmap;		/* Inodes bitmap block */
61
	uint	bg_inode_table;		/* Inodes table block */
62
	ushort	bg_free_blocks_count;	/* Free blocks count */
63
	ushort	bg_free_inodes_count;	/* Free inodes count */
64
	ushort	bg_used_dirs_count;	/* Directories count */
65
	ushort	bg_pad;
66
	uint	bg_reserved[3];
67
};
68
 
69
/*
70
 * Constants relative to the data blocks
71
 */
72
#define	EXT2_NDIR_BLOCKS		12
73
#define	EXT2_IND_BLOCK			EXT2_NDIR_BLOCKS
74
#define	EXT2_DIND_BLOCK			(EXT2_IND_BLOCK + 1)
75
#define	EXT2_TIND_BLOCK			(EXT2_DIND_BLOCK + 1)
76
#define	EXT2_N_BLOCKS			(EXT2_TIND_BLOCK + 1)
77
 
78
/*
79
 * Structure of an inode on the disk
80
 */
81
struct Inode {
82
	ushort i_mode;		/* File mode */
83
	ushort i_uid;		/* Owner Uid */
84
	uint  i_size;		/* Size in bytes */
85
	uint  i_atime;		/* Access time */
86
	uint i_ctime;		/* Creation time */
87
	uint  i_mtime;		/* Modification time */
88
	uint  i_dtime;		/* Deletion Time */
89
	ushort i_gid;		/* Group Id */
90
	ushort i_links_count;	/* Links count */
91
	uint  i_blocks;	/* Blocks count */
92
	uint  i_flags;		/* File flags */
93
	uint osd1;				
94
	uint	i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
95
	uint	i_version;	/* File version (for NFS) */
96
	uint	i_file_acl;	/* File ACL */
97
	uint	i_dir_acl;	/* Directory ACL */
98
	uint	i_faddr;		/* Fragment address */
99
	uchar osd2[12];
100
};
101
 
102
/*
103
 * Structure of a directory entry
104
 */
105
#define EXT2_NAME_LEN 255
106
#define DIR_REC_LEN(name_len)	(((name_len) + 8 + 3) & ~3)
107
 
108
struct DirEntry {
109
	uint	inode;			/* Inode number */
110
	ushort	rec_len;		/* Directory entry length */
111
	uchar	name_len;		/* Name length */
112
	uchar	reserved;
113
	char	name[EXT2_NAME_LEN];	/* File name */
114
};
115
 
116
#define S_IFMT  00170000
117
#define S_IFLNK	 0120000
118
#define S_IFREG  0100000
119
#define S_IFDIR  0040000
120
 
121
#define S_ISLNK(m)	(((m) & S_IFMT) == S_IFLNK)
122
#define S_ISREG(m)	(((m) & S_IFMT) == S_IFREG)
123
#define S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
124
 
125
#define DEFAULT_UID	200
126
#define DEFAULT_GID	100
127
 
128
struct Iobuf
129
{
130
	Xfs *dev;
131
	long	addr;
132
	Iobuf *next;
133
	Iobuf *prev;
134
	Iobuf *hash;
135
	int busy;
136
	int dirty;
137
	char *iobuf;
138
};
139
 
140
struct Xfs{
141
	Xfs *next;
142
	char *name;		/* of file containing external f.s. */
143
	Qid	qid;		/* of file containing external f.s. */
144
	long	ref;		/* attach count */
145
	Qid	rootqid;	/* of plan9 constructed root directory */
146
	short	dev;
147
	short	fmt;
148
	void *ptr; 
149
 
150
	/* data from super block */
151
 
152
	int block_size;
153
	int desc_per_block;
154
	int inodes_per_group;
155
	int inodes_per_block;
156
	int addr_per_block;
157
	int blocks_per_group;
158
 
159
	int ngroups;
160
	int superaddr, superoff;
161
	int grpaddr;
162
};
163
 
164
struct Xfile{
165
	Xfile *next;		/* in hash bucket */
166
	long	client;
167
	long	fid;
168
	Xfs *	xf;
169
	void *	ptr;
170
 
171
	uint inbr;		/* inode nbr */
172
	uint pinbr;	/* parrent inode */
173
	ulong bufaddr;	/* addr of inode block */
174
	ulong bufoffset;
175
	int root;		/* true on attach for ref count */
176
	int dirindex;	/* next dir entry to read */
177
};
178
 
179
#define EXT2_SUPER		1
180
#define EXT2_DESC		2
181
#define EXT2_BBLOCK	3
182
#define EXT2_BINODE	4
183
 
184
struct Ext2{
185
	char type;
186
	union{
187
		SuperBlock *sb;
188
		GroupDesc *gd;
189
		char *bmp;
190
	}u;
191
	Iobuf *buf;
192
};
193
 
194
#define DESC_ADDR(xf,n)		( (xf)->grpaddr + ((n)/(xf)->desc_per_block) )
195
#define DESC_OFFSET(xf,d,n)	( ((GroupDesc *)(d)) + ((n)%(xf)->desc_per_block) )
196
 
197
enum{
198
	Asis, Clean, Clunk
199
};
200
 
201
enum{
202
	Enevermind,
203
	Eformat,
204
	Eio,
205
	Enomem,
206
	Enonexist,
207
	Eexist,
208
	Eperm,
209
	Enofilsys,
210
	Eauth,
211
	Enospace,
212
	Elink,
213
	Elongname,
214
	Eintern,
215
	Ecorrupt,
216
	Enotclean
217
};
218
 
219
extern int	chatty;
220
extern int	errno;
221
extern char	*deffile;
222
extern int rdonly;