RTEMS 6.1-rc6
Loading...
Searching...
No Matches
rtems-rfs-block-pos.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
23/*
24 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
25 *
26 * Redistribution and use in source and binary forms, with or without
27 * modification, are permitted provided that the following conditions
28 * are met:
29 * 1. Redistributions of source code must retain the above copyright
30 * notice, this list of conditions and the following disclaimer.
31 * 2. Redistributions in binary form must reproduce the above copyright
32 * notice, this list of conditions and the following disclaimer in the
33 * documentation and/or other materials provided with the distribution.
34 *
35 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
36 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
37 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
38 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
39 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
40 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
41 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
42 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
43 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
44 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
45 * POSSIBILITY OF SUCH DAMAGE.
46 */
47
48#if !defined (_RTEMS_RFS_BLOCK_POS_H_)
49#define _RTEMS_RFS_BLOCK_POS_H_
50
53
59
63typedef uint32_t rtems_rfs_block_off;
64
71{
77
82
88
90
97#define rtems_rfs_block_copy_bpos(_lhs, _rhs) \
98 do { (_lhs)->bno = (_rhs)->bno; \
99 (_lhs)->boff = (_rhs)->boff; \
100 (_lhs)->block = (_rhs)->block; } while (0)
101
107static inline void
108rtems_rfs_block_set_bpos_zero (rtems_rfs_block_pos* bpos)
109{
110 bpos->bno = 0;
111 bpos->boff = 0;
112 bpos->block = 0;
113}
114
123 rtems_rfs_pos pos,
124 rtems_rfs_block_pos* bpos);
125
135 rtems_rfs_block_pos* bpos);
136
145static inline void
146rtems_rfs_block_add_pos (rtems_rfs_file_system* fs,
147 rtems_rfs_pos_rel offset,
149{
151 rtems_rfs_block_get_pos (fs, bpos) + offset,
152 bpos);
153 bpos->block = 0;
154}
155
161{
167
173
175
182#define rtems_rfs_block_copy_size(_lhs, _rhs) \
183 do { (_lhs)->count = (_rhs)->count; \
184 (_lhs)->offset = (_rhs)->offset; } while (0)
185
189#define rtems_rfs_block_pos_last_block(_p, _s) \
190 ((((_p)->bno == 0) && ((_s)->count == 0)) || ((_p)->bno == ((_s)->count - 1)))
191
195#define rtems_rfs_block_pos_past_end(_p, _s) \
196 (((_p)->bno && ((_s)->count == 0)) || \
197 ((_p)->bno >= (_s)->count) || \
198 (((_p)->bno == ((_s)->count - 1)) && ((_p)->boff > (_s)->offset)))
199
203#define rtems_rfs_block_pos_block_past_end(_p, _s) \
204 (((_p)->bno && ((_s)->count == 0)) || ((_p)->bno >= (_s)->count))
205
210#define rtems_rfs_block_size_get_bpos(_s, _b) \
211 do { (_b)->bno = (_s)->count; \
212 (_b)->boff = (_s)->offset; \
213 (_b)->block = 0; \
214 if ((_b)->boff) --(_b)->bno; } while (0)
215
219#define rtems_rfs_block_size_equal(_lhs, _rhs) \
220 (((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->offset))
221
227static inline void
228rtems_rfs_block_set_size_zero (rtems_rfs_block_size* size)
229{
230 size->count = 0;
231 size->offset = 0;
232}
233
242 rtems_rfs_pos pos,
244
260
261#endif
void rtems_rfs_block_get_bpos(rtems_rfs_file_system *fs, rtems_rfs_pos pos, rtems_rfs_block_pos *bpos)
Definition: rtems-rfs-block.c:68
rtems_rfs_pos rtems_rfs_block_get_size(rtems_rfs_file_system *fs, rtems_rfs_block_size *size)
Definition: rtems-rfs-block.c:98
void rtems_rfs_block_get_block_size(rtems_rfs_file_system *fs, rtems_rfs_pos pos, rtems_rfs_block_size *size)
Definition: rtems-rfs-block.c:84
struct rtems_rfs_block_pos_s rtems_rfs_block_pos
rtems_rfs_pos rtems_rfs_block_get_pos(rtems_rfs_file_system *fs, rtems_rfs_block_pos *bpos)
Definition: rtems-rfs-block.c:77
struct rtems_rfs_block_size_s rtems_rfs_block_size
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
RTEMS File System Data.
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:109
int64_t rtems_rfs_pos_rel
Definition: rtems-rfs-file-system.h:114
RTEMS File System Information Node.
uint32_t rtems_rfs_inode_block
Definition: rtems-rfs-inode.h:108
Definition: rtems-rfs-file-system.h:135
Definition: rtems-rfs-block-pos.h:71
rtems_rfs_block_off boff
Definition: rtems-rfs-block-pos.h:81
rtems_rfs_block_no bno
Definition: rtems-rfs-block-pos.h:76
rtems_rfs_block_no block
Definition: rtems-rfs-block-pos.h:87
Definition: rtems-rfs-block-pos.h:161
rtems_rfs_block_off offset
Definition: rtems-rfs-block-pos.h:172
rtems_rfs_block_no count
Definition: rtems-rfs-block-pos.h:166