RTEMS
5.0.0
|
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_shared * | rtems_rfs_file_get_shared (rtems_rfs_file_system *fs, rtems_rfs_ino ino) |
RTEMS File System File Support.
RTEMS File System File Support
This file provides the support functions.
#define rtems_rfs_file_block | ( | _f | ) | ((_f)->bpos.bno) |
Return the file's block number given a file handle.
#define rtems_rfs_file_block_offset | ( | _f | ) | ((_f)->bpos.boff) |
Return the file's block offset given a file handle.
#define rtems_rfs_file_bpos | ( | _f | ) | (&(_f)->bpos) |
Return the file's block position pointer given a file handle.
#define rtems_rfs_file_buffer | ( | _f | ) | (&(_f)->buffer) |
Return the file's buffer handle pointer given a file handle.
#define rtems_rfs_file_data | ( | _f | ) | (rtems_rfs_buffer_data (&(_f)->buffer) + (_f)->bpos.boff) |
Access the data in the buffer.
#define rtems_rfs_file_fs | ( | _f | ) | ((_f)->shared->fs) |
Return the file system data pointer given a file handle.
#define rtems_rfs_file_get_size | ( | _f | ) | (&(_f)->shared->size) |
Return the shared size varable.
#define rtems_rfs_file_inode | ( | _f | ) | (&(_f)->shared->inode) |
Return the file's inode handle pointer given a file handle.
#define rtems_rfs_file_map | ( | _f | ) | (&(_f)->shared->map) |
Return the file's block map pointer given a file handle.
#define RTEMS_RFS_FILE_NO_ATIME_UPDATE (1 << 0) |
File flags.Do not update the atime field in the inode if set.
#define RTEMS_RFS_FILE_NO_LENGTH_UPDATE (1 << 2) |
Do not update the position field in the inode if set.
#define RTEMS_RFS_FILE_NO_MTIME_UPDATE (1 << 1) |
Do not update the mtime field in the inode if set.
#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).
#define rtems_rfs_file_size | ( | _f | ) | rtems_rfs_file_shared_get_size (rtems_rfs_file_fs (_f), (_f)->shared) |
Return the size of file.
#define rtems_rfs_file_size_count | ( | _f | ) | rtems_rfs_file_shared_get_block_count ((_f)->shared) |
Return the file block count.
#define rtems_rfs_file_size_offset | ( | _f | ) | rtems_rfs_file_shared_get_block_offset ((_f)->shared) |
Return the file block offset.
#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.
#define rtems_rfs_file_update_length | ( | _f | ) | (((_f)->flags & RTEMS_RFS_FILE_NO_LENGTH_UPDATE) == 0) |
Update the length field of the inode.
#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 struct _rtems_rfs_file_handle rtems_rfs_file_handle |
File data used to managed an open file.
typedef struct _rtems_rfs_file_shared 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.
int rtems_rfs_file_close | ( | rtems_rfs_file_system * | fs, |
rtems_rfs_file_handle * | handle | ||
) |
Close an open file handle.
[in] | fs | is the file system. |
[in] | handle | is the open file handle. |
0 | Successful operation. |
error_code | An error occurred. |
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.
[in] | fs | is the file system data. |
[in] | ino | is the inode number to locate the data for. |
shared | The shared data. |
NULL | No shared file data is located. |
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.
[in] | handle | is the file handle. |
[in] | size | is the amount of data read or written. |
[in] | read | is the I/O was a read if true else it was a write. |
0 | Successful operation. |
error_code | An error occurred. |
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.
[in] | handle | is the file handle. |
0 | Successful operation. |
error_code | An error occurred. |
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.
[in] | handle | is the file handle. |
[in] | available | is the amount of data available for I/O. |
[in] | read | is the I/O operation is a read so the block is read from the media. |
0 | Successful operation. |
error_code | An error occurred. |
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.
[in] | fs | is the file system. |
[in] | ino | is the inode number of the file to be opened. |
[out] | handle | will be filled in with the handle pointer. |
0 | Successful operation. |
error_code | An error occurred. |
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.
[in] | handle | The file handle. |
[in] | pos | is the position to seek to. |
[out] | new_pos | will contain the actual position. |
0 | Successful operation. |
error_code | An error occurred. |
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.
[in] | handle | is the file handle. |
[in] | size | is the new size of the file. |
0 | Successful operation. |
error_code | An error occurred. |