RTEMS
5.1
|
RTEMS File Systems Block Management. More...
#include <rtems/rfs/rtems-rfs-block-pos.h>
#include <rtems/rfs/rtems-rfs-buffer.h>
#include <rtems/rfs/rtems-rfs-data.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
Go to the source code of this file.
Data Structures | |
struct | rtems_rfs_block_map_s |
Macros | |
#define | rtems_rfs_block_get_number(_h, _b) |
#define | rtems_rfs_block_set_number(_h, _b, _n) |
#define | rtems_rfs_block_map_is_dirty(_m) ((_m)->dirty) |
#define | rtems_rfs_block_map_count(_m) ((_m)->size.count) |
#define | rtems_rfs_block_map_size(_m) (&((_m)->size)) |
#define | rtems_rfs_block_map_size_offset(_m) ((_m)->size.offset) |
#define | rtems_rfs_block_map_last(_m) rtems_rfs_block_pos_last_block (&(_m)->bpos, &(_m)->size) |
#define | rtems_rfs_block_map_past_end(_m, _p) rtems_rfs_block_pos_past_end (_p, &(_m)->size) |
#define | rtems_rfs_block_map_pos(_f, _m) rtems_rfs_block_get_pos (_f, &(_m)->bpos) |
#define | rtems_rfs_block_map_block(_m) ((_m)->bpos.bno) |
#define | rtems_rfs_block_map_block_offset(_m) ((_m)->bpos.boff) |
Typedefs | |
typedef struct rtems_rfs_block_map_s | rtems_rfs_block_map |
Functions | |
int | rtems_rfs_block_map_open (rtems_rfs_file_system *fs, rtems_rfs_inode_handle *inode, rtems_rfs_block_map *map) |
int | rtems_rfs_block_map_close (rtems_rfs_file_system *fs, rtems_rfs_block_map *map) |
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) |
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) |
int | rtems_rfs_block_map_next_block (rtems_rfs_file_system *fs, rtems_rfs_block_map *map, rtems_rfs_buffer_block *block) |
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) |
int | rtems_rfs_block_map_shrink (rtems_rfs_file_system *fs, rtems_rfs_block_map *map, size_t blocks) |
int | rtems_rfs_block_map_free_all (rtems_rfs_file_system *fs, rtems_rfs_block_map *map) |
RTEMS File Systems Block Management.
RTEMS File Systems Block Management.
These functions manage the blocks used in the file system.
#define rtems_rfs_block_get_number | ( | _h, | |
_b | |||
) |
Get a block number in the media format and return it in the host format.
[in] | _h | is the buffer handle of the block. |
[in] | _b | is the block number index. |
block | The block number. |
#define rtems_rfs_block_map_block | ( | _m | ) | ((_m)->bpos.bno) |
Return the map's current block number.
#define rtems_rfs_block_map_block_offset | ( | _m | ) | ((_m)->bpos.boff) |
Return the map's current block offset.
#define rtems_rfs_block_map_count | ( | _m | ) | ((_m)->size.count) |
Return the block count in the map.
#define rtems_rfs_block_map_is_dirty | ( | _m | ) | ((_m)->dirty) |
Is the map dirty ?
#define rtems_rfs_block_map_last | ( | _m | ) | rtems_rfs_block_pos_last_block (&(_m)->bpos, &(_m)->size) |
Are we at the last block in the map ?
#define rtems_rfs_block_map_past_end | ( | _m, | |
_p | |||
) | rtems_rfs_block_pos_past_end (_p, &(_m)->size) |
Is the position past the end of the block ?
#define rtems_rfs_block_map_pos | ( | _f, | |
_m | |||
) | rtems_rfs_block_get_pos (_f, &(_m)->bpos) |
Return the current position in the map.
#define rtems_rfs_block_map_size | ( | _m | ) | (&((_m)->size)) |
Return the map's size element.
#define rtems_rfs_block_map_size_offset | ( | _m | ) | ((_m)->size.offset) |
Return the size offset for the map.
#define rtems_rfs_block_set_number | ( | _h, | |
_b, | |||
_n | |||
) |
Set a block number in the media format given a number in the host format.
[in] | _h | is the buffer handle of the block. |
[in] | _b | is the block number index, ie the number of block number not the buffer offset. |
[in] | _n | is the block number. |
typedef struct rtems_rfs_block_map_s rtems_rfs_block_map |
A block map manges the block lists that originate from an inode. The inode contains a number of block numbers. A block map takes those block numbers and manages them.
The blocks cannot have all ones as a block number nor block 0. The block map is series of block numbers in a blocks. The size of the map determines the way the block numbers are stored. The map uses the following:
Direct access has the blocks numbers in the inode slots. The Single Indirect Access has block numbers in the inode slots that pointer to a table of block numbers that point to data blocks. The Double Indirect Access has block numbers in the inode that point to Single Indirect block tables.
The inode can hold a number of Direct, Single Indirect, and Double Indirect block tables. The move from Direct to Single occurs then the block count in the map is above the number of slots in the inode. The move from Single to Double occurs when the map block count is greated than the block numbers per block multipled by the slots in the inode. The move from Single to Double occurs when the map block count is over the block numbers per block squared multipled by the number of slots in the inode.
The block map can managed files of the follow size verses block size with 5 inode slots:
int rtems_rfs_block_map_close | ( | rtems_rfs_file_system * | fs, |
rtems_rfs_block_map * | map | ||
) |
Close the map. The buffer handles are closed and any help buffers are released.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the map that is opened. |
0 | Successful operation. |
error_code | An error occurred. |
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 | ||
) |
Find a block number in the map from the position provided.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the map to search. |
[in] | bpos | is a pointer to the block position to find. |
[out] | block | will contain the block in when found. |
0 | Successful operation. |
error_code | An error occurred. |
int rtems_rfs_block_map_free_all | ( | rtems_rfs_file_system * | fs, |
rtems_rfs_block_map * | map | ||
) |
Free all blocks in the map.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the open map to free all blocks from. |
0 | Successful operation. |
error_code | An error occurred. |
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 | ||
) |
Grow the block map by the specified number of blocks.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the open map to grow. |
[in] | blocks | is the number of blocks to grow the map by. |
[out] | new_block | will contain first of the blocks allocated to the map. |
0 | Successful operation. |
error_code | An error occurred. |
int rtems_rfs_block_map_next_block | ( | rtems_rfs_file_system * | fs, |
rtems_rfs_block_map * | map, | ||
rtems_rfs_buffer_block * | block | ||
) |
Seek to the next block.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the map to search. |
[out] | block | will contain the block in when found. |
0 | Successful operation. |
ENXIO | Failed to seek because it is outside the block map. |
error_code | An error occurred. |
int rtems_rfs_block_map_open | ( | rtems_rfs_file_system * | fs, |
rtems_rfs_inode_handle * | inode, | ||
rtems_rfs_block_map * | map | ||
) |
Open a block map. The block map data in the inode is copied into the map. The buffer handles are opened. The block position is set to the start so a seek of offset 0 will return the first block.
[in] | fs | is the file system data. |
[in] | inode | is a pointer to the inode the map belongs to. |
[in] | map | is a pointer to the map that is opened. |
0 | Successful operation. |
error_code | An error occurred. |
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 | ||
) |
Seek around the map.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the map to search. |
[in] | offset | is the distance to seek. It is signed. |
[out] | block | will contain the block in when found. |
0 | Successful operation. |
ENXIO | Failed to seek because it is outside the block map. |
error_code | An error occurred. |
int rtems_rfs_block_map_shrink | ( | rtems_rfs_file_system * | fs, |
rtems_rfs_block_map * | map, | ||
size_t | blocks | ||
) |
Grow the block map by the specified number of blocks.
[in] | fs | is the file system data. |
[in] | map | is a pointer to the open map to shrink. |
[in] | blocks | is the number of blocks to shrink the map by. If more than the number of blocks the map is emptied. |
0 | Successful operation. |
error_code | An error occurred. |