RTEMS 6.1-rc1
rtems-rfs-file-system.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
15/*
16 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
17 *
18 * Redistribution and use in source and binary forms, with or without
19 * modification, are permitted provided that the following conditions
20 * are met:
21 * 1. Redistributions of source code must retain the above copyright
22 * notice, this list of conditions and the following disclaimer.
23 * 2. Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
38 */
39
40#if !defined (_RTEMS_RFS_FILE_SYSTEM_H_)
41#define _RTEMS_RFS_FILE_SYSTEM_H_
42
44
48#define RTEMS_RFS_SB_OFFSET_MAGIC (0)
49#define RTEMS_RFS_SB_MAGIC (0x28092001)
50#define RTEMS_RFS_SB_OFFSET_VERSION (RTEMS_RFS_SB_OFFSET_MAGIC + 4)
51#define RTEMS_RFS_SB_OFFSET_BLOCK_SIZE (RTEMS_RFS_SB_OFFSET_VERSION + 4)
52#define RTEMS_RFS_SB_OFFSET_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCK_SIZE + 4)
53#define RTEMS_RFS_SB_OFFSET_BAD_BLOCKS (RTEMS_RFS_SB_OFFSET_BLOCKS + 4)
54#define RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH (RTEMS_RFS_SB_OFFSET_BAD_BLOCKS + 4)
55#define RTEMS_RFS_SB_OFFSET_GROUPS (RTEMS_RFS_SB_OFFSET_MAX_NAME_LENGTH + 4)
56#define RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS (RTEMS_RFS_SB_OFFSET_GROUPS + 4)
57#define RTEMS_RFS_SB_OFFSET_GROUP_INODES (RTEMS_RFS_SB_OFFSET_GROUP_BLOCKS + 4)
58#define RTEMS_RFS_SB_OFFSET_INODE_SIZE (RTEMS_RFS_SB_OFFSET_GROUP_INODES + 4)
59
63#define RTEMS_RFS_VERSION (0x00000000)
64
69#define RTEMS_RFS_VERSION_MASK INT32_C(0x00000000)
70
75#define RTEMS_RFS_ROOT_INO (1)
76
80#define RTEMS_RFS_EMPTY_INO (0)
81
86#define RTEMS_RFS_INODE_BLOCKS (5)
87
93#define RTEMS_RFS_INODE_OVERHEAD_PERCENTAGE (1)
94
99#define RTEMS_RFS_SUPERBLOCK_SIZE (1)
100
104#define RTEMS_RFS_FS_MAX_HELD_BUFFERS (5)
105
109typedef uint64_t rtems_rfs_pos;
110
114typedef int64_t rtems_rfs_pos_rel;
115
119#define RTEMS_RFS_FS_BITMAPS_HOLD (1 << 0)
122#define RTEMS_RFS_FS_NO_LOCAL_CACHE (1 << 1)
126#define RTEMS_RFS_FS_FORCE_OPEN (1 << 2)
128#define RTEMS_RFS_FS_READ_ONLY (1 << 3)
135{
139 uint32_t flags;
140
146 size_t blocks;
147
153
158
159#if RTEMS_RFS_USE_LIBBLOCK
165 rtems_disk_device* disk;
166#else
170 size_t size;
171#endif
172
176 uint32_t inodes;
177
182 uint32_t bad_blocks;
183
188
193
198
203
208
213
218
224
231
236
241
246
252
257
263
268
274
278 void* user;
279};
280
286#define rtems_rfs_fs_flags(_f) ((_f)->flags)
292#define rtems_rfs_fs_release_bitmaps(_f) (!((_f)->flags & RTEMS_RFS_FS_BITMAPS_HOLD))
293
299#define rtems_rfs_fs_no_local_cache(_f) ((_f)->flags & RTEMS_RFS_FS_NO_LOCAL_CACHE)
300
306#if RTEMS_RFS_USE_LIBBLOCK
307#define rtems_rfs_fs_device(_fs) ((_fs)->disk)
308#else
309#define rtems_rfs_fs_device(_fs) ((_fs)->device)
310#endif
311
317#define rtems_rfs_fs_blocks(_fs) ((_fs)->blocks)
318
324#define rtems_rfs_fs_block_size(_fs) ((_fs)->block_size)
325
331#define rtems_rfs_fs_inodes(_fs) ((_fs)->inodes)
332
342#define rtems_rfs_fs_block(_fs, _grp, _blk) \
343 ((((_fs)->group_blocks) * (_grp)) + (_blk) + 1)
344
350#if RTEMS_RFS_USE_LIBBLOCK
351#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->disk->size)
352#else
353#define rtems_rfs_fs_media_blocks(_fs) ((_fs)->media_size)
354#endif
355
362#if RTEMS_RFS_USE_LIBBLOCK
363#define rtems_rfs_fs_media_block_size(_fs) ((_fs)->disk->media_block_size)
364#else
365#define rtems_rfs_fs_media_block_size(_fs) (1)
366#endif
367
371#define rtems_rfs_fs_max_name(_fs) ((_fs)->max_name_length)
372
378#define rtems_rfs_fs_max_block_map_blocks(_fs) ((_fs)->block_map_doubly_blocks)
379
383#define rtems_rfs_fs_user(_fs) ((_fs)->user)
384
392
400
413int rtems_rfs_fs_open (const char* name,
414 void* user,
415 uint32_t flags,
416 uint32_t max_held_buffers,
418
428
429#endif
uint64_t rtems_rfs_fs_size(rtems_rfs_file_system *fs)
Definition: rtems-rfs-file-system.c:51
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:215
uint64_t rtems_rfs_fs_media_size(rtems_rfs_file_system *fs)
Definition: rtems-rfs-file-system.c:59
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:109
int rtems_rfs_fs_close(rtems_rfs_file_system *fs)
Definition: rtems-rfs-file-system.c:329
int64_t rtems_rfs_pos_rel
Definition: rtems-rfs-file-system.h:114
RTEMS File Systems Group Management.
Definition: rtems-rfs-file-system.h:135
uint32_t release_count
Definition: rtems-rfs-file-system.h:256
rtems_chain_control file_shares
Definition: rtems-rfs-file-system.h:273
uint32_t release_modified_count
Definition: rtems-rfs-file-system.h:267
size_t inodes_per_block
Definition: rtems-rfs-file-system.h:212
rtems_chain_control release
Definition: rtems-rfs-file-system.h:251
rtems_rfs_group * groups
Definition: rtems-rfs-file-system.h:192
uint32_t buffers_count
Definition: rtems-rfs-file-system.h:245
size_t blocks_per_block
Definition: rtems-rfs-file-system.h:217
size_t block_map_doubly_blocks
Definition: rtems-rfs-file-system.h:230
size_t block_map_singly_blocks
Definition: rtems-rfs-file-system.h:223
uint32_t max_held_buffers
Definition: rtems-rfs-file-system.h:235
size_t size
Definition: rtems-rfs-file-system.h:170
void * user
Definition: rtems-rfs-file-system.h:278
int device
Definition: rtems-rfs-file-system.h:157
size_t blocks
Definition: rtems-rfs-file-system.h:146
uint32_t flags
Definition: rtems-rfs-file-system.h:139
size_t group_blocks
Definition: rtems-rfs-file-system.h:202
uint32_t bad_blocks
Definition: rtems-rfs-file-system.h:182
int group_count
Definition: rtems-rfs-file-system.h:197
size_t block_size
Definition: rtems-rfs-file-system.h:152
uint32_t inodes
Definition: rtems-rfs-file-system.h:176
uint32_t max_name_length
Definition: rtems-rfs-file-system.h:187
rtems_chain_control release_modified
Definition: rtems-rfs-file-system.h:262
size_t group_inodes
Definition: rtems-rfs-file-system.h:207
rtems_chain_control buffers
Definition: rtems-rfs-file-system.h:240
Creates bit allocator for blocks in the group simpler.
Definition: rtems-rfs-group.h:71
Description of a disk device (logical and physical disks).
Definition: diskdevs.h:177
This union represents a chain control block.
Definition: chain.h:96