RTEMS 6.1-rc2
Loading...
Searching...
No Matches
Functions

RTEMS File Systems Block Routines. More...

#include <inttypes.h>
#include <string.h>
#include <rtems/rfs/rtems-rfs-block.h>
#include <rtems/rfs/rtems-rfs-data.h>
#include <rtems/rfs/rtems-rfs-group.h>
#include <rtems/rfs/rtems-rfs-inode.h>

Functions

void rtems_rfs_block_get_bpos (rtems_rfs_file_system *fs, rtems_rfs_pos pos, rtems_rfs_block_pos *bpos)
 
rtems_rfs_pos rtems_rfs_block_get_pos (rtems_rfs_file_system *fs, rtems_rfs_block_pos *bpos)
 
void rtems_rfs_block_get_block_size (rtems_rfs_file_system *fs, rtems_rfs_pos pos, rtems_rfs_block_size *size)
 
rtems_rfs_pos rtems_rfs_block_get_size (rtems_rfs_file_system *fs, rtems_rfs_block_size *size)
 
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_block_no *block)
 
int rtems_rfs_block_map_seek (rtems_rfs_file_system *fs, rtems_rfs_block_map *map, rtems_rfs_pos_rel offset, rtems_rfs_block_no *block)
 
int rtems_rfs_block_map_next_block (rtems_rfs_file_system *fs, rtems_rfs_block_map *map, rtems_rfs_block_no *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)
 

Detailed Description

RTEMS File Systems Block Routines.

These functions manage blocks in the RFS file system. A block is an area of the media and its size is set for a each specific media. The block size is set when the file system is set up and needs to be matched for it to be read correctly.

Blocks are managed as groups. A block group or "group" is part of the total number of blocks being managed by the file system and exist to allow resources to localised. A file in a directory will be allocated blocks in the same group as the directory, and the blocks for the file will also be allocated in the same group.

A group consist of a block bitmap, inodes and data blocks. The first block of the file system will hold the superblock. The block bitmap is a collection of blocks that hold a map of bits, one bit per block for each block in the group. When a file system is mounted the block bitmaps are read and a summary bit map is made. The summary bitmap has a single bit for 32 bits in the bitmap and is set when all 32 bits it maps to are set. This speeds up the search for a free block by a factor of 32.

Function Documentation

◆ 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 
)

Set the size given a position.

Parameters
[in]fsis the file system data.
[in]posis the position as an absolute offset from the start.
[out]sizeis a pointer to the block size to fill in.

◆ 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 
)

Given a position compute the block number and block offset.

Parameters
[in]fsis the file system data.
[in]posis the position as an absolute offset from the start.
[out]bposis a pointer to the block position to fill in.

◆ rtems_rfs_block_get_pos()

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.

Parameters
[in]fsis the file system data.
[out]bposis a pointer to the block position to fill in.
Return values
offsetThe absolute offset.

◆ rtems_rfs_block_get_size()

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. If the block count is 0 the size is 0. If the block is greater than 0 and the offset is 0 the size is number of blocks multipled by the block size and if the offset is not 0 it is the offset into the last block. For example if blocks is 1 and offset is 0 the size is the block size. If the block count is 1 and size is 100 the size is 100.

Parameters
[in]fsis the file system data.
[in]sizeThe size in blocks and offset.
Return values
sizeThe size in bytes.

◆ rtems_rfs_block_map_close()

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.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the map that is opened.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_block_map_find()

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.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the map to search.
[in]bposis a pointer to the block position to find.
[out]blockwill contain the block in when found.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_block_map_free_all()

int rtems_rfs_block_map_free_all ( rtems_rfs_file_system fs,
rtems_rfs_block_map map 
)

Free all blocks in the map.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the open map to free all blocks from.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_block_map_grow()

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.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the open map to grow.
[in]blocksis the number of blocks to grow the map by.
[out]new_blockwill contain first of the blocks allocated to the map.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_block_map_next_block()

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.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the map to search.
[out]blockwill contain the block in when found.
Return values
0Successful operation.
ENXIOFailed to seek because it is outside the block map.
error_codeAn error occurred.

◆ rtems_rfs_block_map_open()

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.

Parameters
[in]fsis the file system data.
[in]inodeis a pointer to the inode the map belongs to.
[in]mapis a pointer to the map that is opened.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_block_map_seek()

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.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the map to search.
[in]offsetis the distance to seek. It is signed.
[out]blockwill contain the block in when found.
Return values
0Successful operation.
ENXIOFailed to seek because it is outside the block map.
error_codeAn error occurred.

◆ rtems_rfs_block_map_shrink()

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.

Parameters
[in]fsis the file system data.
[in]mapis a pointer to the open map to shrink.
[in]blocksis the number of blocks to shrink the map by. If more than the number of blocks the map is emptied.
Return values
0Successful operation.
error_codeAn error occurred.