RTEMS: cpukit/include/rtems/rfs/rtems-rfs-block-pos.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
rtems-rfs-block-pos.h
Go to the documentation of this file.
1
21/*
22 * COPYRIGHT (c) 2010 Chris Johns <chrisj@rtems.org>
23 *
24 * The license and distribution terms for this file may be
25 * found in the file LICENSE in this distribution or at
26 * http://www.rtems.org/license/LICENSE.
27 */
28
29#if !defined (_RTEMS_RFS_BLOCK_POS_H_)
30#define _RTEMS_RFS_BLOCK_POS_H_
31
32#include <rtems/rfs/rtems-rfs-file-system.h>
33#include <rtems/rfs/rtems-rfs-inode.h>
34
39 typedef rtems_rfs_inode_block rtems_rfs_block_no;
40
44 typedef uint32_t rtems_rfs_block_off;
45
51 typedef struct rtems_rfs_block_pos_s
52{
57 rtems_rfs_block_no bno;
58
62 rtems_rfs_block_off boff;
63
68 rtems_rfs_block_no block;
69
70} rtems_rfs_block_pos;
71
78#define rtems_rfs_block_copy_bpos(_lhs, _rhs) \
79 do { (_lhs)->bno = (_rhs)->bno; \
80 (_lhs)->boff = (_rhs)->boff; \
81 (_lhs)->block = (_rhs)->block; } while (0)
82
88static inline void
89rtems_rfs_block_set_bpos_zero (rtems_rfs_block_pos* bpos)
90{
91 bpos->bno = 0;
92 bpos->boff = 0;
93 bpos->block = 0;
94}
95
103void rtems_rfs_block_get_bpos (rtems_rfs_file_system* fs,
104 rtems_rfs_pos pos,
105 rtems_rfs_block_pos* bpos);
106
115 rtems_rfs_pos rtems_rfs_block_get_pos (rtems_rfs_file_system* fs,
116 rtems_rfs_block_pos* bpos);
117
126static inline void
127rtems_rfs_block_add_pos (rtems_rfs_file_system* fs,
128 rtems_rfs_pos_rel offset,
129 rtems_rfs_block_pos* bpos)
130{
131 rtems_rfs_block_get_bpos (fs,
132 rtems_rfs_block_get_pos (fs, bpos) + offset,
133 bpos);
134 bpos->block = 0;
135}
136
141 typedef struct rtems_rfs_block_size_s
142{
147 rtems_rfs_block_no count;
148
153 rtems_rfs_block_off offset;
154
155} rtems_rfs_block_size;
156
163#define rtems_rfs_block_copy_size(_lhs, _rhs) \
164 do { (_lhs)->count = (_rhs)->count; \
165 (_lhs)->offset = (_rhs)->offset; } while (0)
166
170#define rtems_rfs_block_pos_last_block(_p, _s) \
171 ((((_p)->bno == 0) && ((_s)->count == 0)) || ((_p)->bno == ((_s)->count - 1)))
172
176#define rtems_rfs_block_pos_past_end(_p, _s) \
177 (((_p)->bno && ((_s)->count == 0)) || \
178 ((_p)->bno >= (_s)->count) || \
179 (((_p)->bno == ((_s)->count - 1)) && ((_p)->boff > (_s)->offset)))
180
184#define rtems_rfs_block_pos_block_past_end(_p, _s) \
185 (((_p)->bno && ((_s)->count == 0)) || ((_p)->bno >= (_s)->count))
186
191#define rtems_rfs_block_size_get_bpos(_s, _b) \
192 do { (_b)->bno = (_s)->count; \
193 (_b)->boff = (_s)->offset; \
194 (_b)->block = 0; \
195 if ((_b)->boff) --(_b)->bno; } while (0)
196
200#define rtems_rfs_block_size_equal(_lhs, _rhs) \
201 (((_lhs)->count == (_rhs)->count) && ((_lhs)->offset == (_rhs)->offset))
202
208static inline void
209rtems_rfs_block_set_size_zero (rtems_rfs_block_size* size)
210{
211 size->count = 0;
212 size->offset = 0;
213}
214
222void rtems_rfs_block_get_block_size (rtems_rfs_file_system* fs,
223 rtems_rfs_pos pos,
224 rtems_rfs_block_size* size);
225
239 rtems_rfs_pos rtems_rfs_block_get_size (rtems_rfs_file_system* fs,
240 rtems_rfs_block_size* size);
241
242#endif
rtems_rfs_block_get_bpos
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:49
rtems_rfs_block_get_size
rtems_rfs_pos rtems_rfs_block_get_size(rtems_rfs_file_system *fs, rtems_rfs_block_size *size)
Definition: rtems-rfs-block.c:79
rtems_rfs_block_get_block_size
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:65
rtems_rfs_block_pos
struct rtems_rfs_block_pos_s rtems_rfs_block_pos
rtems_rfs_block_get_pos
rtems_rfs_pos rtems_rfs_block_get_pos(rtems_rfs_file_system *fs, rtems_rfs_block_pos *bpos)
Definition: rtems-rfs-block.c:58
rtems_rfs_block_size
struct rtems_rfs_block_size_s rtems_rfs_block_size
rtems_rfs_block_no
rtems_rfs_inode_block rtems_rfs_block_no
Definition: rtems-rfs-block-pos.h:39
rtems_rfs_block_off
uint32_t rtems_rfs_block_off
Definition: rtems-rfs-block-pos.h:44
rtems-rfs-file-system.h
RTEMS File System Data.
rtems_rfs_pos
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:90
rtems_rfs_pos_rel
int64_t rtems_rfs_pos_rel
Definition: rtems-rfs-file-system.h:95
rtems-rfs-inode.h
RTEMS File System Information Node.
rtems_rfs_inode_block
uint32_t rtems_rfs_inode_block
Definition: rtems-rfs-inode.h:89
_rtems_rfs_file_system
Definition: rtems-rfs-file-system.h:116
rtems_rfs_block_pos_s
Definition: rtems-rfs-block-pos.h:52
rtems_rfs_block_pos_s::boff
rtems_rfs_block_off boff
Definition: rtems-rfs-block-pos.h:62
rtems_rfs_block_pos_s::bno
rtems_rfs_block_no bno
Definition: rtems-rfs-block-pos.h:57
rtems_rfs_block_pos_s::block
rtems_rfs_block_no block
Definition: rtems-rfs-block-pos.h:68
rtems_rfs_block_size_s
Definition: rtems-rfs-block-pos.h:142
rtems_rfs_block_size_s::offset
rtems_rfs_block_off offset
Definition: rtems-rfs-block-pos.h:153
rtems_rfs_block_size_s::count
rtems_rfs_block_no count
Definition: rtems-rfs-block-pos.h:147