RTEMS CPU Kit with SuperCore  4.11.3
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 
40 
44 typedef uint32_t rtems_rfs_block_off;
45 
51 typedef struct rtems_rfs_block_pos_s
52 {
58 
63 
69 
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 
88 static inline void
89 rtems_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 
104  rtems_rfs_pos pos,
105  rtems_rfs_block_pos* bpos);
106 
116  rtems_rfs_block_pos* bpos);
117 
126 static inline void
127 rtems_rfs_block_add_pos (rtems_rfs_file_system* fs,
128  rtems_rfs_pos_rel offset,
129  rtems_rfs_block_pos* bpos)
130 {
132  rtems_rfs_block_get_pos (fs, bpos) + offset,
133  bpos);
134  bpos->block = 0;
135 }
136 
142 {
148 
154 
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 
208 static inline void
209 rtems_rfs_block_set_size_zero (rtems_rfs_block_size* size)
210 {
211  size->count = 0;
212  size->offset = 0;
213 }
214 
223  rtems_rfs_pos pos,
224  rtems_rfs_block_size* size);
225 
240  rtems_rfs_block_size* size);
241 
242 #endif
struct rtems_rfs_block_size_s rtems_rfs_block_size
A block size is the number of blocks less one plus the offset where the offset must be less than the ...
A block size is the number of blocks less one plus the offset where the offset must be less than the ...
Definition: rtems-rfs-block-pos.h:141
rtems_rfs_pos rtems_rfs_block_get_size(rtems_rfs_file_system *fs, rtems_rfs_block_size *size)
Calculate the position given the number of blocks and the offset.
Definition: rtems-rfs-block.c:78
void rtems_rfs_block_get_block_size(rtems_rfs_file_system *fs, rtems_rfs_pos pos, rtems_rfs_block_size *size)
Set the size given a position.
Definition: rtems-rfs-block.c:64
uint32_t rtems_rfs_inode_block
The size of a block value on disk.
Definition: rtems-rfs-inode.h:89
struct rtems_rfs_block_pos_s rtems_rfs_block_pos
A block position is a block number times the block size plus the offset.
RFS File System data.
Definition: rtems-rfs-file-system.h:123
uint64_t rtems_rfs_pos
Absolute position.
Definition: rtems-rfs-file-system.h:90
rtems_rfs_inode_block rtems_rfs_block_no
The block number is the same type as the inode block number.
Definition: rtems-rfs-block-pos.h:39
uint32_t rtems_rfs_block_off
The offset into a block.
Definition: rtems-rfs-block-pos.h:44
rtems_rfs_block_off offset
The offset into the block.
Definition: rtems-rfs-block-pos.h:153
rtems_rfs_pos rtems_rfs_block_get_pos(rtems_rfs_file_system *fs, rtems_rfs_block_pos *bpos)
Given a block position compute the absolute offset.
Definition: rtems-rfs-block.c:57
rtems_rfs_block_off boff
The offset into the block.
Definition: rtems-rfs-block-pos.h:62
A block position is a block number times the block size plus the offset.
Definition: rtems-rfs-block-pos.h:51
rtems_rfs_block_no count
The count of blocks in a map.
Definition: rtems-rfs-block-pos.h:147
rtems_rfs_block_no block
The block number that the bpos + boff map to.
Definition: rtems-rfs-block-pos.h:68
void rtems_rfs_block_get_bpos(rtems_rfs_file_system *fs, rtems_rfs_pos pos, rtems_rfs_block_pos *bpos)
Given a position compute the block number and block offset.
Definition: rtems-rfs-block.c:48
int64_t rtems_rfs_pos_rel
Relative position.
Definition: rtems-rfs-file-system.h:95
rtems_rfs_block_no bno
The block index in the map.
Definition: rtems-rfs-block-pos.h:57