RTEMS  5.1
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 
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,
225 
241 
242 #endif
struct rtems_rfs_block_size_s rtems_rfs_block_size
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)
Definition: rtems-rfs-block.c:79
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
uint32_t rtems_rfs_inode_block
Definition: rtems-rfs-inode.h:89
struct rtems_rfs_block_pos_s rtems_rfs_block_pos
RTEMS File System Data.
Definition: rtems-rfs-file-system.h:123
uint64_t rtems_rfs_pos
Definition: rtems-rfs-file-system.h:90
rtems_rfs_inode_block rtems_rfs_block_no
Definition: rtems-rfs-block-pos.h:39
uint32_t rtems_rfs_block_off
Definition: rtems-rfs-block-pos.h:44
rtems_rfs_block_off offset
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)
Definition: rtems-rfs-block.c:58
rtems_rfs_block_off boff
Definition: rtems-rfs-block-pos.h:62
Definition: rtems-rfs-block-pos.h:51
RTEMS File System Information Node.
rtems_rfs_block_no count
Definition: rtems-rfs-block-pos.h:147
rtems_rfs_block_no block
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)
Definition: rtems-rfs-block.c:49
unsigned size
Definition: tte.h:74
int64_t rtems_rfs_pos_rel
Definition: rtems-rfs-file-system.h:95
rtems_rfs_block_no bno
Definition: rtems-rfs-block-pos.h:57