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>
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
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
35 #ifndef __CHFS_MEDIA_H__
36 #define __CHFS_MEDIA_H__
40 typedef uint16_t le16
;
41 typedef uint32_t le32
;
42 typedef uint64_t le64
;
45 /*****************************************************************************/
46 /* File system specific structures */
47 /*****************************************************************************/
50 CHFS_NODETYPE_VNODE
= 1,
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
68 * struct chfs_flash_node_hdr - node header, its members are same for
69 * all nodes, used at scan
70 * @magic: filesystem magic
72 * @length: length of node
73 * @hdr_crc: crc of the first 3 members
75 struct chfs_flash_node_hdr
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
93 * @mode: permissions for vnode
94 * @dn_size: size of written out data nodes
95 * @atime: last access times
96 * @mtime: last modification time
98 * @dsize: size of the node's data
99 * @node_crc: crc of full node
101 struct chfs_flash_vnode
117 le32 node_crc
; /*60*/
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
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
159 * @nsize: length of name
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
185 * struct chfs_flash_padding_node - node informations of data stored on
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
200 #endif /* __CHFS_MEDIA_H__ */