RTEMS 6.1-rc1
Data Structures | Macros | Typedefs | Functions

RTEMS File System File Support. More...

#include <rtems/libio_.h>
#include <rtems/rfs/rtems-rfs-block.h>
#include <rtems/rfs/rtems-rfs-data.h>
#include <rtems/rfs/rtems-rfs-file-system.h>
#include <rtems/rfs/rtems-rfs-inode.h>

Go to the source code of this file.

Data Structures

struct  _rtems_rfs_file_shared
 
struct  _rtems_rfs_file_handle
 

Macros

#define RTEMS_RFS_FILE_NO_ATIME_UPDATE   (1 << 0)
 
#define RTEMS_RFS_FILE_NO_MTIME_UPDATE   (1 << 1)
 
#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE   (1 << 2)
 
#define rtems_rfs_file_data(_f)    (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff)
 
#define rtems_rfs_file_fs(_f)   ((_f)->shared->fs)
 
#define rtems_rfs_file_inode(_f)   (&(_f)->shared->inode)
 
#define rtems_rfs_file_map(_f)   (&(_f)->shared->map)
 
#define rtems_rfs_file_bpos(_f)   (&(_f)->bpos)
 
#define rtems_rfs_file_block(_f)   ((_f)->bpos.bno)
 
#define rtems_rfs_file_block_offset(_f)   ((_f)->bpos.boff)
 
#define rtems_rfs_file_set_bpos(_f, _p)    rtems_rfs_block_get_bpos (rtems_rfs_file_fs (_f), _p, (&(_f)->bpos))
 
#define rtems_rfs_file_buffer(_f)   (&(_f)->buffer)
 
#define rtems_rfs_file_update_atime(_f)    (((_f)->flags & RTEMS_RFS_FILE_NO_ATIME_UPDATE) == 0)
 
#define rtems_rfs_file_update_mtime(_f)    (((_f)->flags & RTEMS_RFS_FILE_NO_MTIME_UPDATE) == 0)
 
#define rtems_rfs_file_update_length(_f)    (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0)
 
#define rtems_rfs_file_get_size(_f)    (&(_f)->shared->size)
 
#define rtems_rfs_file_size(_f)    rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared)
 
#define rtems_rfs_file_size_count(_f)    rtems_rfs_file_shared_get_block_count ((_f)->shared)
 
#define rtems_rfs_file_size_offset(_f)    rtems_rfs_file_shared_get_block_offset ((_f)->shared)
 

Typedefs

typedef struct _rtems_rfs_file_shared rtems_rfs_file_shared
 
typedef struct _rtems_rfs_file_handle rtems_rfs_file_handle
 

Functions

int rtems_rfs_file_open (rtems_rfs_file_system *fs, rtems_rfs_ino ino, int oflag, rtems_rfs_file_handle **handle)
 
int rtems_rfs_file_close (rtems_rfs_file_system *fs, rtems_rfs_file_handle *handle)
 
int rtems_rfs_file_io_start (rtems_rfs_file_handle *handle, size_t *available, bool read)
 
int rtems_rfs_file_io_end (rtems_rfs_file_handle *handle, size_t size, bool read)
 
int rtems_rfs_file_io_release (rtems_rfs_file_handle *handle)
 
int rtems_rfs_file_seek (rtems_rfs_file_handle *handle, rtems_rfs_pos pos, rtems_rfs_pos *new_pos)
 
int rtems_rfs_file_set_size (rtems_rfs_file_handle *handle, rtems_rfs_pos size)
 
rtems_rfs_file_sharedrtems_rfs_file_get_shared (rtems_rfs_file_system *fs, rtems_rfs_ino ino)
 

Detailed Description

RTEMS File System File Support.

RTEMS File System File Support

This file provides the support functions.

Macro Definition Documentation

◆ rtems_rfs_file_block

#define rtems_rfs_file_block (   _f)    ((_f)->bpos.bno)

Return the file's block number given a file handle.

◆ rtems_rfs_file_block_offset

#define rtems_rfs_file_block_offset (   _f)    ((_f)->bpos.boff)

Return the file's block offset given a file handle.

◆ rtems_rfs_file_bpos

#define rtems_rfs_file_bpos (   _f)    (&(_f)->bpos)

Return the file's block position pointer given a file handle.

◆ rtems_rfs_file_buffer

#define rtems_rfs_file_buffer (   _f)    (&(_f)->buffer)

Return the file's buffer handle pointer given a file handle.

◆ rtems_rfs_file_data

#define rtems_rfs_file_data (   _f)     (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff)

Access the data in the buffer.

◆ rtems_rfs_file_fs

#define rtems_rfs_file_fs (   _f)    ((_f)->shared->fs)

Return the file system data pointer given a file handle.

◆ rtems_rfs_file_get_size

#define rtems_rfs_file_get_size (   _f)     (&(_f)->shared->size)

Return the shared size varable.

◆ rtems_rfs_file_inode

#define rtems_rfs_file_inode (   _f)    (&(_f)->shared->inode)

Return the file's inode handle pointer given a file handle.

◆ rtems_rfs_file_map

#define rtems_rfs_file_map (   _f)    (&(_f)->shared->map)

Return the file's block map pointer given a file handle.

◆ RTEMS_RFS_FILE_NO_ATIME_UPDATE

#define RTEMS_RFS_FILE_NO_ATIME_UPDATE   (1 << 0)

File flags. Do not update the atime field in the inode if set.

◆ RTEMS_RFS_FILE_NO_LENGTH_UPDATE

#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE   (1 << 2)

Do not update the position field in the inode if set.

◆ RTEMS_RFS_FILE_NO_MTIME_UPDATE

#define RTEMS_RFS_FILE_NO_MTIME_UPDATE   (1 << 1)

Do not update the mtime field in the inode if set.

◆ rtems_rfs_file_set_bpos

#define rtems_rfs_file_set_bpos (   _f,
  _p 
)     rtems_rfs_block_get_bpos (rtems_rfs_file_fs (_f), _p, (&(_f)->bpos))

Set the file's block position given a file position (absolute).

◆ rtems_rfs_file_size

#define rtems_rfs_file_size (   _f)     rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared)

Return the size of file.

◆ rtems_rfs_file_size_count

#define rtems_rfs_file_size_count (   _f)     rtems_rfs_file_shared_get_block_count ((_f)->shared)

Return the file block count.

◆ rtems_rfs_file_size_offset

#define rtems_rfs_file_size_offset (   _f)     rtems_rfs_file_shared_get_block_offset ((_f)->shared)

Return the file block offset.

◆ rtems_rfs_file_update_atime

#define rtems_rfs_file_update_atime (   _f)     (((_f)->flags & RTEMS_RFS_FILE_NO_ATIME_UPDATE) == 0)

Update the access time field of the inode when reading if flagged to do so.

◆ rtems_rfs_file_update_length

#define rtems_rfs_file_update_length (   _f)     (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0)

Update the length field of the inode.

◆ rtems_rfs_file_update_mtime

#define rtems_rfs_file_update_mtime (   _f)     (((_f)->flags & RTEMS_RFS_FILE_NO_MTIME_UPDATE) == 0)

Update the modified time field of the inode when writing if flagged to do so.

Typedef Documentation

◆ rtems_rfs_file_handle

File data used to managed an open file.

◆ rtems_rfs_file_shared

File data that is shared by various file handles accessing the same file. We hold various inode values common to the file that can change frequently so the inode is not thrashed yet we meet the requirements of the POSIX standard. The stat call needs to check the shared file data.

Function Documentation

◆ rtems_rfs_file_close()

int rtems_rfs_file_close ( rtems_rfs_file_system fs,
rtems_rfs_file_handle handle 
)

Close an open file handle.

Parameters
[in]fsis the file system.
[in]handleis the open file handle.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_file_get_shared()

rtems_rfs_file_shared * rtems_rfs_file_get_shared ( rtems_rfs_file_system fs,
rtems_rfs_ino  ino 
)

Return the shared file data for an ino.

Parameters
[in]fsis the file system data.
[in]inois the inode number to locate the data for.
Returns
rtems_rfs_file_shared* The shared data or NULL is not located.
Return values
sharedThe shared data.
NULLNo shared file data is located.

◆ rtems_rfs_file_io_end()

int rtems_rfs_file_io_end ( rtems_rfs_file_handle handle,
size_t  size,
bool  read 
)

End the I/O. Any buffers held in the file handle and returned to the cache. If inode updating is not disable and the I/O is a read the atime field is updated and if a write I/O the mtime is updated.

If the file's position is updated by the size amount.

Parameters
[in]handleis the file handle.
[in]sizeis the amount of data read or written.
[in]readis the I/O was a read if true else it was a write.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_file_io_release()

int rtems_rfs_file_io_release ( rtems_rfs_file_handle handle)

Release the I/O resources without any changes. If data has changed in the buffer and the buffer was not already released as modified the data will be lost.

Parameters
[in]handleis the file handle.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_file_io_start()

int rtems_rfs_file_io_start ( rtems_rfs_file_handle handle,
size_t *  available,
bool  read 
)

Start I/O on a block of a file. This call only requests the block from the media if reading and makes the buffer available to you the via the rtems_rfs_file_data interface after the call. The available amount data is taken from the current file position until the end of the block. The file position is not adujsted until the I/O ends. An I/O request cannot perform I/O past the end of a block so the call returns the amount of data available.

Parameters
[in]handleis the file handle.
[in]availableis the amount of data available for I/O.
[in]readis the I/O operation is a read so the block is read from the media.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_file_open()

int rtems_rfs_file_open ( rtems_rfs_file_system fs,
rtems_rfs_ino  ino,
int  oflag,
rtems_rfs_file_handle **  handle 
)

Open a file handle.

Parameters
[in]fsis the file system.
[in]inois the inode number of the file to be opened.
[out]handlewill be filled in with the handle pointer.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_file_seek()

int rtems_rfs_file_seek ( rtems_rfs_file_handle handle,
rtems_rfs_pos  pos,
rtems_rfs_pos new_pos 
)

The file to the position returning the old position. The position is abolute.

Parameters
[in]handleThe file handle.
[in]posis the position to seek to.
[out]new_poswill contain the actual position.
Return values
0Successful operation.
error_codeAn error occurred.

◆ rtems_rfs_file_set_size()

int rtems_rfs_file_set_size ( rtems_rfs_file_handle handle,
rtems_rfs_pos  size 
)

Set the size of the file to the new size. This can extend the file to a new size.

Parameters
[in]handleis the file handle.
[in]sizeis the new size of the file.
Return values
0Successful operation.
error_codeAn error occurred.