VM: only single page chunks
[minix.git] / sys / ufs / chfs / media.h
blob1f94131a9b34a20f987668b7751a6cd38c20cf5e
1 /*-
2 * Copyright (c) 2010 Department of Software Engineering,
3 * University of Szeged, Hungary
4 * Copyright (C) 2009 Ferenc Havasi <havasi@inf.u-szeged.hu>
5 * Copyright (C) 2009 Zoltan Sogor <weth@inf.u-szeged.hu>
6 * Copyright (C) 2009 David Tengeri <dtengeri@inf.u-szeged.hu>
7 * Copyright (C) 2010 Adam Hoka <ahoka@NetBSD.org>
8 * All rights reserved.
10 * This code is derived from software contributed to The NetBSD Foundation
11 * by the Department of Software Engineering, University of Szeged, Hungary
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 * 1. Redistributions of source code must retain the above copyright
17 * notice, this list of conditions and the following disclaimer.
18 * 2. Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in the
20 * documentation and/or other materials provided with the distribution.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 #ifndef __CHFS_MEDIA_H__
36 #define __CHFS_MEDIA_H__
38 #ifndef _LE_TYPES
39 #define _LE_TYPES
40 typedef uint16_t le16;
41 typedef uint32_t le32;
42 typedef uint64_t le64;
43 #endif
45 /*****************************************************************************/
46 /* File system specific structures */
47 /*****************************************************************************/
49 enum {
50 CHFS_NODETYPE_VNODE = 1,
51 CHFS_NODETYPE_DATA,
52 CHFS_NODETYPE_DIRENT,
53 CHFS_NODETYPE_PADDING,
56 //#define CHFS_NODE_HDR_SIZE 12 /* magic + type + length + hdr_crc */
57 #define CHFS_NODE_HDR_SIZE sizeof(struct chfs_flash_node_hdr)
59 /* Max size we have to read to get all info.
60 * It is max size of chfs_flash_dirent_node with max name length.
62 #define CHFS_MAX_NODE_SIZE 299
64 /* This will identify CHfs nodes */
65 #define CHFS_FS_MAGIC_BITMASK 0x4AF1
67 /**
68 * struct chfs_flash_node_hdr - node header, its members are same for
69 * all nodes, used at scan
70 * @magic: filesystem magic
71 * @type: node type
72 * @length: length of node
73 * @hdr_crc: crc of the first 3 members
75 struct chfs_flash_node_hdr
77 le16 magic;
78 le16 type;
79 le32 length;
80 le32 hdr_crc;
81 } __packed;
83 /**
84 * struct chfs_flash_vnode - vnode informations stored on flash
85 * @magic: filesystem magic
86 * @type: node type (CHFS_NODETYPE_VNODE)
87 * @length: length of node
88 * @hdr_crc: crc of the first 3 members
89 * @vno: vnode identifier id
90 * @version: vnode's version number
91 * @uid: owner of the file
92 * @gid: group of file
93 * @mode: permissions for vnode
94 * @dn_size: size of written out data nodes
95 * @atime: last access times
96 * @mtime: last modification time
97 * @ctime: change time
98 * @dsize: size of the node's data
99 * @node_crc: crc of full node
101 struct chfs_flash_vnode
103 le16 magic; /*0 */
104 le16 type; /*2 */
105 le32 length; /*4 */
106 le32 hdr_crc; /*8 */
107 le64 vno; /*12*/
108 le64 version; /*20*/
109 le32 uid; /*28*/
110 le32 gid; /*32*/
111 le32 mode; /*36*/
112 le32 dn_size; /*40*/
113 le32 atime; /*44*/
114 le32 mtime; /*48*/
115 le32 ctime; /*52*/
116 le32 dsize; /*56*/
117 le32 node_crc; /*60*/
118 } __packed;
121 * struct chfs_flash_data_node - node informations of data stored on flash
122 * @magic: filesystem magic
123 * @type: node type (CHFS_NODETYPE_DATA)
124 * @length: length of node with data
125 * @hdr_crc: crc of the first 3 members
126 * @vno: vnode identifier id
127 * @version: vnode's version number
128 * @offset: offset in the file where write begins
129 * @data_length: length of data
130 * @data_crc: crc of data
131 * @node_crc: crc of full node
132 * @data: array of data
134 struct chfs_flash_data_node
136 le16 magic;
137 le16 type;
138 le32 length;
139 le32 hdr_crc;
140 le64 vno;
141 le64 version;
142 le64 offset;
143 le32 data_length;
144 le32 data_crc;
145 le32 node_crc;
146 uint8_t data[0];
147 } __packed;
150 * struct chfs_flash_dirent_node - vnode informations stored on flash
151 * @magic: filesystem magic
152 * @type: node type (CHFS_NODETYPE_DIRENT)
153 * @length: length of node
154 * @hdr_crc: crc of the first 3 members
155 * @vno: vnode identifier id
156 * @pvno: vnode identifier id of parent vnode
157 * @version: vnode's version number
158 * @mctime:
159 * @nsize: length of name
160 * @dtype: file type
161 * @unused: just for padding
162 * @name_crc: crc of name
163 * @node_crc: crc of full node
164 * @name: name of the directory entry
166 struct chfs_flash_dirent_node
168 le16 magic;
169 le16 type;
170 le32 length;
171 le32 hdr_crc;
172 le64 vno;
173 le64 pvno;
174 le64 version;
175 le32 mctime;
176 uint8_t nsize;
177 uint8_t dtype;
178 uint8_t unused[2];
179 le32 name_crc;
180 le32 node_crc;
181 uint8_t name[0];
182 } __packed;
185 * struct chfs_flash_padding_node - node informations of data stored on
186 * flash
187 * @magic: filesystem magic
188 * @type: node type (CHFS_NODETYPE_PADDING)
189 * @length: length of node
190 * @hdr_crc: crc of the first 3 members
192 struct chfs_flash_padding_node
194 le16 magic;
195 le16 type;
196 le32 length;
197 le32 hdr_crc;
198 } __packed;
200 #endif /* __CHFS_MEDIA_H__ */