RTEMS 6.1-rc1
rtems-rfs-block.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
41#if !defined (_RTEMS_RFS_BLOCK_H_)
42#define _RTEMS_RFS_BLOCK_H_
43
48
57#define rtems_rfs_block_get_number(_h, _b) \
58 ((rtems_rfs_block_no) \
59 (rtems_rfs_read_u32 (rtems_rfs_buffer_data (_h) + \
60 ((_b) * sizeof (rtems_rfs_block_no)))))
61
70#define rtems_rfs_block_set_number(_h, _b, _n) \
71 do { \
72 rtems_rfs_write_u32 (rtems_rfs_buffer_data (_h) + \
73 ((_b) * sizeof (rtems_rfs_block_no)), (_n)); \
74 rtems_rfs_buffer_mark_dirty (_h); \
75 } while (0)
76
112{
116 bool dirty;
117
122
127
137
143
149
154
159
164
166
170#define rtems_rfs_block_map_is_dirty(_m) ((_m)->dirty)
171
175#define rtems_rfs_block_map_count(_m) ((_m)->size.count)
176
180#define rtems_rfs_block_map_size(_m) (&((_m)->size))
181
185#define rtems_rfs_block_map_size_offset(_m) ((_m)->size.offset)
186
190#define rtems_rfs_block_map_last(_m) \
191 rtems_rfs_block_pos_last_block (&(_m)->bpos, &(_m)->size)
192
196#define rtems_rfs_block_map_past_end(_m, _p) \
197 rtems_rfs_block_pos_past_end (_p, &(_m)->size)
198
202#define rtems_rfs_block_map_pos(_f, _m) \
203 rtems_rfs_block_get_pos (_f, &(_m)->bpos)
204
208#define rtems_rfs_block_map_block(_m) ((_m)->bpos.bno)
209
213#define rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff)
214
221static inline void
222rtems_rfs_block_map_set_size_offset (rtems_rfs_block_map* map,
223 rtems_rfs_block_off offset)
224{
225 map->size.offset = offset;
226 map->dirty = true;
227}
228
235static inline void
236rtems_rfs_block_map_set_size (rtems_rfs_block_map* map,
238{
240 map->dirty = true;
241}
257
270
286
301 rtems_rfs_pos_rel offset,
303
318
333 size_t blocks,
334 rtems_rfs_block_no* new_block);
335
349 size_t blocks);
350
362
363#endif
RTEMS File Systems Block Position and Size Management.
#define rtems_rfs_block_copy_size(_lhs, _rhs)
Definition: rtems-rfs-block-pos.h:182
rtems_rfs_inode_block rtems_rfs_block_no
Definition: rtems-rfs-block-pos.h:58
uint32_t rtems_rfs_block_off
Definition: rtems-rfs-block-pos.h:63
int rtems_rfs_block_map_seek(rtems_rfs_file_system *fs, rtems_rfs_block_map *map, rtems_rfs_pos_rel offset, rtems_rfs_buffer_block *block)
Definition: rtems-rfs-block.c:352
int rtems_rfs_block_map_shrink(rtems_rfs_file_system *fs, rtems_rfs_block_map *map, size_t blocks)
Definition: rtems-rfs-block.c:668
int rtems_rfs_block_map_free_all(rtems_rfs_file_system *fs, rtems_rfs_block_map *map)
Definition: rtems-rfs-block.c:815
int rtems_rfs_block_map_find(rtems_rfs_file_system *fs, rtems_rfs_block_map *map, rtems_rfs_block_pos *bpos, rtems_rfs_buffer_block *block)
Definition: rtems-rfs-block.c:252
int rtems_rfs_block_map_open(rtems_rfs_file_system *fs, rtems_rfs_inode_handle *inode, rtems_rfs_block_map *map)
Definition: rtems-rfs-block.c:114
struct rtems_rfs_block_map_s rtems_rfs_block_map
int rtems_rfs_block_map_next_block(rtems_rfs_file_system *fs, rtems_rfs_block_map *map, rtems_rfs_buffer_block *block)
Definition: rtems-rfs-block.c:364
int rtems_rfs_block_map_close(rtems_rfs_file_system *fs, rtems_rfs_block_map *map)
Definition: rtems-rfs-block.c:165
int rtems_rfs_block_map_grow(rtems_rfs_file_system *fs, rtems_rfs_block_map *map, size_t blocks, rtems_rfs_block_no *new_block)
Definition: rtems-rfs-block.c:425
Maps Blocks to the Media Interface Layers.
uint32_t rtems_rfs_buffer_block
Definition: rtems-rfs-buffer.h:81
RTEMS File System Data.
RTEMS File System Data.
#define RTEMS_RFS_INODE_BLOCKS
Definition: rtems-rfs-file-system.h:86
int64_t rtems_rfs_pos_rel
Definition: rtems-rfs-file-system.h:114
Definition: mm.c:60
Definition: rtems-rfs-file-system.h:135
Definition: rtems-rfs-inode.h:201
Definition: rtems-rfs-block.h:112
rtems_rfs_buffer_handle singly_buffer
Definition: rtems-rfs-block.h:158
rtems_rfs_block_pos bpos
Definition: rtems-rfs-block.h:136
rtems_rfs_block_size size
Definition: rtems-rfs-block.h:126
rtems_rfs_inode_handle * inode
Definition: rtems-rfs-block.h:121
uint32_t blocks[RTEMS_RFS_INODE_BLOCKS]
Definition: rtems-rfs-block.h:153
rtems_rfs_block_no last_map_block
Definition: rtems-rfs-block.h:142
bool dirty
Definition: rtems-rfs-block.h:116
rtems_rfs_block_no last_data_block
Definition: rtems-rfs-block.h:148
rtems_rfs_buffer_handle doubly_buffer
Definition: rtems-rfs-block.h:163
Definition: rtems-rfs-block-pos.h:71
Definition: rtems-rfs-block-pos.h:161
Definition: rtems-rfs-buffer.h:111
unsigned size
Definition: tte.h:1