RTEMS  5.1
rtems-rfs-file-system.h
Go to the documentation of this file.
1 
13 /*
14  * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
15  *
16  * The license and distribution terms for this file may be
17  * found in the file LICENSE in this distribution or at
18  * http://www.rtems.org/license/LICENSE.
19  */
20 
21 #if !defined (_RTEMS_RFS_FILE_SYSTEM_H_)
22 #define _RTEMS_RFS_FILE_SYSTEM_H_
23 
25 
29 #define RTEMS_RFS_SB_OFFSET_MAGIC (0)
30 #define RTEMS_RFS_SB_MAGIC (0x28092001)
31 #define RTEMS_RFS_SB_OFFSET_VERSION (RTEMS_RFS_SB_OFFSET_MAGIC + 4)
32 #define RTEMS_RFS_SB_OFFSET_BLOCK_SIZE (RTEMS_RFS_SB_OFFSET_VERSION + 4)
33 #define RTEMS_RFS_SB_OFFSET_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCK_SIZE + 4)
34 #define RTEMS_RFS_SB_OFFSET_BAD_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCKS + 4)
35 #define RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH (RTEMS_RFS_SB_OFFSET_BAD_BLOCKS + 4)
36 #define RTEMS_RFS_SB_OFFSET_GROUPS (RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH + 4)
37 #define RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS (RTEMS_RFS_SB_OFFSET_GROUPS + 4)
38 #define RTEMS_RFS_SB_OFFSET_GROUP_INODES (RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS + 4)
39 #define RTEMS_RFS_SB_OFFSET_INODE_SIZE (RTEMS_RFS_SB_OFFSET_GROUP_INODES + 4)
40 
44 #define RTEMS_RFS_VERSION (0x00000000)
45 
50 #define RTEMS_RFS_VERSION_MASK INT32_C(0x00000000)
51 
56 #define RTEMS_RFS_ROOT_INO (1)
57 
61 #define RTEMS_RFS_EMPTY_INO (0)
62 
67 #define RTEMS_RFS_INODE_BLOCKS (5)
68 
74 #define RTEMS_RFS_INODE_OVERHEAD_PERCENTAGE (1)
75 
80 #define RTEMS_RFS_SUPERBLOCK_SIZE (1)
81 
85 #define RTEMS_RFS_FS_MAX_HELD_BUFFERS (5)
86 
90 typedef uint64_t rtems_rfs_pos;
91 
95 typedef int64_t rtems_rfs_pos_rel;
96 
100 #define RTEMS_RFS_FS_BITMAPS_HOLD (1 << 0)
103 #define RTEMS_RFS_FS_NO_LOCAL_CACHE (1 << 1)
107 #define RTEMS_RFS_FS_FORCE_OPEN (1 << 2)
109 #define RTEMS_RFS_FS_READ_ONLY (1 << 3)
115 struct _rtems_rfs_file_system
116 {
120  uint32_t flags;
121 
127  size_t blocks;
133  size_t block_size;
134 
138  int device;
139 
140 #if RTEMS_RFS_USE_LIBBLOCK
147 #else
148 
151  size_t size;
152 #endif
153 
157  uint32_t inodes;
158 
163  uint32_t bad_blocks;
164 
168  uint32_t max_name_length;
169 
174 
178  int group_count;
179 
183  size_t group_blocks;
184 
188  size_t group_inodes;
189 
193  size_t inodes_per_block;
194 
198  size_t blocks_per_block;
199 
205 
216  uint32_t max_held_buffers;
217 
222 
226  uint32_t buffers_count;
227 
233 
237  uint32_t release_count;
238 
244 
248  uint32_t release_modified_count;
249 
255 
259  void* user;
260 };
261 
267 #define rtems_rfs_fs_flags(_f) ((_f)->flags)
268 
273 #define rtems_rfs_fs_release_bitmaps(_f) (!((_f)->flags & RTEMS_RFS_FS_BITMAPS_HOLD))
274 
280 #define rtems_rfs_fs_no_local_cache(_f) ((_f)->flags & RTEMS_RFS_FS_NO_LOCAL_CACHE)
287 #if RTEMS_RFS_USE_LIBBLOCK
288 #define rtems_rfs_fs_device(_fs) ((_fs)->disk)
289 #else
290 #define rtems_rfs_fs_device(_fs) ((_fs)->device)
291 #endif
292 
298 #define rtems_rfs_fs_blocks(_fs) ((_fs)->blocks)
299 
305 #define rtems_rfs_fs_block_size(_fs) ((_fs)->block_size)
312 #define rtems_rfs_fs_inodes(_fs) ((_fs)->inodes)
323 #define rtems_rfs_fs_block(_fs, _grp, _blk) \
324  ((((_fs)->group_blocks) * (_grp)) + (_blk) + 1)
325 
331 #if RTEMS_RFS_USE_LIBBLOCK
332 #define rtems_rfs_fs_media_blocks(_fs) ((_fs)->disk->size)
333 #else
334 #define rtems_rfs_fs_media_blocks(_fs) ((_fs)->media_size)
335 #endif
336 
343 #if RTEMS_RFS_USE_LIBBLOCK
344 #define rtems_rfs_fs_media_block_size(_fs) ((_fs)->disk->media_block_size)
345 #else
346 #define rtems_rfs_fs_media_block_size(_fs) (1)
347 #endif
348 
352 #define rtems_rfs_fs_max_name(_fs) ((_fs)->max_name_length)
353 
359 #define rtems_rfs_fs_max_block_map_blocks(_fs) ((_fs)->block_map_doubly_blocks)
364 #define rtems_rfs_fs_user(_fs) ((_fs)->user)
365 
373 
381 
394 int rtems_rfs_fs_open (const char* name,
395  void* user,
396  uint32_t flags,
397  uint32_t max_held_buffers,
398  rtems_rfs_file_system** fs);
399 
409 
410 #endif
int rtems_rfs_fs_close(rtems_rfs_file_system *fs)
Definition: rtems-rfs-file-system.c:310
uint32_t release_modified_count
Definition: rtems-rfs-file-system.h:256
Creates bit allocator for blocks in the group simpler.
Definition: rtems-rfs-group.h:51
uint32_t release_count
Definition: rtems-rfs-file-system.h:245
uint32_t bad_blocks
Definition: rtems-rfs-file-system.h:171
uint32_t max_held_buffers
Definition: rtems-rfs-file-system.h:224
size_t group_blocks
Definition: rtems-rfs-file-system.h:191
int device
Definition: rtems-rfs-file-system.h:146
rtems_rfs_group * groups
Definition: rtems-rfs-file-system.h:181
Definition: chain.h:86
void * user
Definition: rtems-rfs-file-system.h:267
uint32_t inodes
Definition: rtems-rfs-file-system.h:165
uint64_t rtems_rfs_fs_media_size(rtems_rfs_file_system *fs)
Definition: rtems-rfs-file-system.c:40
rtems_chain_control buffers
Definition: rtems-rfs-file-system.h:229
size_t block_size
Definition: rtems-rfs-file-system.h:141
Definition: rtems-rfs-file-system.h:123
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:90
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:157
uint32_t buffers_count
Definition: rtems-rfs-file-system.h:234
RTEMS File Systems Group Management.
rtems_chain_control release
Definition: rtems-rfs-file-system.h:240
size_t block_map_singly_blocks
Definition: rtems-rfs-file-system.h:212
int group_count
Definition: rtems-rfs-file-system.h:186
size_t inodes_per_block
Definition: rtems-rfs-file-system.h:201
size_t group_inodes
Definition: rtems-rfs-file-system.h:196
size_t blocks
Definition: rtems-rfs-file-system.h:135
size_t block_map_doubly_blocks
Definition: rtems-rfs-file-system.h:219
uint32_t max_name_length
Definition: rtems-rfs-file-system.h:176
size_t blocks_per_block
Definition: rtems-rfs-file-system.h:206
rtems_chain_control release_modified
Definition: rtems-rfs-file-system.h:251
rtems_chain_control file_shares
Definition: rtems-rfs-file-system.h:262
uint32_t flags
Definition: rtems-rfs-file-system.h:128
uint64_t rtems_rfs_fs_size(rtems_rfs_file_system *fs)
Definition: rtems-rfs-file-system.c:32
unsigned size
Definition: tte.h:74
int64_t rtems_rfs_pos_rel
Definition: rtems-rfs-file-system.h:95
int rtems_rfs_fs_open(const char *name, void *user, uint32_t flags, uint32_t max_held_buffers, rtems_rfs_file_system **fs)
Definition: rtems-rfs-file-system.c:196