RTEMS  5.0.0
Modules | Files | Data Structures | Macros | Typedefs | Functions | Variables
In-Memory File System Support

In-Memory File System Support. More...

Modules

 IMFS Device IO Handler
 

Files

file  deviceio.c
 IMFS Device Node Handlers.
 
file  imfs_chown.c
 IMFS Change Owner.
 
file  imfs_config.c
 IMFS Limits and Options.
 
file  imfs_creat.c
 Create an IMFS Node.
 
file  imfs_dir.c
 
file  imfs_dir_default.c
 
file  imfs_dir_minimal.c
 
file  imfs_eval.c
 Evaluation IMFS Node Support.
 
file  imfs_fchmod.c
 Change IMFS File Mode.
 
file  imfs_fifo.c
 FIFO Support.
 
file  imfs_fsunmount.c
 Unmount this Instance of IMFS.
 
file  imfs_handlers_device.c
 Device Operations Table.
 
file  imfs_initsupp.c
 IMFS Node Support.
 
file  imfs_linfile.c
 
 
file  imfs_load_tar.c
 RTEMS Load Tarfs.
 
file  imfs_make_generic_node.c
 IMFS Make a Generic Node.
 
file  imfs_memfile.c
 IMFS Memory File Handlers.
 
file  imfs_mknod.c
 Create a IMFS Node.
 
file  imfs_mount.c
 Mount an IMFS.
 
file  imfs_node.c
 IMFS Node Support.
 
file  imfs_rename.c
 IMFS Rename.
 
file  imfs_rmnod.c
 IMFS Node Removal Handler.
 
file  imfs_stat.c
 IMFS Stat.
 
file  imfs_stat_file.c
 
 
file  imfs_unmount.c
 Unmount an IMFS.
 
file  imfs_utime.c
 Set IMFS File Access and Modification Times.
 

Data Structures

struct  IMFS_jnode_tt
 
struct  IMFS_directory_t
 
struct  IMFS_device_t
 
struct  IMFS_link_t
 
struct  IMFS_sym_link_t
 
struct  IMFS_filebase_t
 
struct  IMFS_memfile_t
 
struct  IMFS_linearfile_t
 
union  IMFS_file_t
 
struct  IMFS_fifo_t
 
struct  IMFS_generic_t
 
struct  IMFS_mknod_controls
 
struct  IMFS_fs_info_t
 
struct  IMFS_mount_data
 

Macros

#define IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK   128
 
#define IMFS_MEMFILE_BYTES_PER_BLOCK   imfs_memfile_bytes_per_block
 
#define IMFS_MEMFILE_BLOCK_SLOTS   (IMFS_MEMFILE_BYTES_PER_BLOCK / sizeof(void *))
 
#define FIRST_INDIRECT   (0)
 
#define LAST_INDIRECT   (IMFS_MEMFILE_BLOCK_SLOTS - 1)
 
#define FIRST_DOUBLY_INDIRECT   (LAST_INDIRECT + 1)
 
#define LAST_DOUBLY_INDIRECT
 
#define FIRST_TRIPLY_INDIRECT   (LAST_DOUBLY_INDIRECT + 1)
 
#define LAST_TRIPLY_INDIRECT
 
#define IMFS_MEMFILE_MAXIMUM_SIZE   (LAST_TRIPLY_INDIRECT * IMFS_MEMFILE_BYTES_PER_BLOCK)
 
#define IMFS_NAME_MAX   _POSIX_NAME_MAX
 
#define IMFS_NODE_FLAG_NAME_ALLOCATED   0x1
 
#define IMFS_assert(_x)
 
#define IMFS_STAT_FMT_HARD_LINK   0
 

Typedefs

typedef struct IMFS_jnode_tt IMFS_jnode_t
 
typedef uint8_t * block_p
 
typedef block_p * block_ptr
 

Functions

int IMFS_initialize (rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
 
int IMFS_initialize_support (rtems_filesystem_mount_table_entry_t *mt_entry, const void *data)
 
void IMFS_fsunmount (rtems_filesystem_mount_table_entry_t *mt_entry)
 Unmount this instance of IMFS.
 
int rtems_tarfs_load (const char *mountpoint, uint8_t *tar_image, size_t tar_size)
 RTEMS load tarfs. More...
 
void IMFS_node_destroy (IMFS_jnode_t *node)
 Destroy an IMFS node.
 
int IMFS_node_clone (rtems_filesystem_location_info_t *loc)
 Clone an IMFS node.
 
void IMFS_node_free (const rtems_filesystem_location_info_t *loc)
 Free an IMFS node.
 
int IMFS_stat (const rtems_filesystem_location_info_t *loc, struct stat *buf)
 Perform a status processing for the IMFS. More...
 
int IMFS_stat_file (const rtems_filesystem_location_info_t *loc, struct stat *buf)
 
void IMFS_eval_path (rtems_filesystem_eval_path_context_t *ctx)
 IMFS evaluation node support.
 
int IMFS_link (const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *targetloc, const char *name, size_t namelen)
 Create a new IMFS link node. More...
 
int IMFS_chown (const rtems_filesystem_location_info_t *loc, uid_t owner, gid_t group)
 Change the owner of IMFS. More...
 
int IMFS_mknod (const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, mode_t mode, dev_t dev)
 Create an IMFS node. More...
 
IMFS_jnode_tIMFS_initialize_node (IMFS_jnode_t *node, const IMFS_node_control *node_control, const char *name, size_t namelen, mode_t mode, void *arg)
 
IMFS_jnode_tIMFS_create_node (const rtems_filesystem_location_info_t *parentloc, const IMFS_node_control *node_control, size_t node_size, const char *name, size_t namelen, mode_t mode, void *arg)
 Create an IMFS node. More...
 
int IMFS_mount (rtems_filesystem_mount_table_entry_t *mt_entry)
 Mount an IMFS.
 
int IMFS_unmount (rtems_filesystem_mount_table_entry_t *mt_entry)
 Unmount an IMFS.
 
int IMFS_utime (const rtems_filesystem_location_info_t *loc, time_t actime, time_t modtime)
 Set IMFS file access and modification times. More...
 
int IMFS_fchmod (const rtems_filesystem_location_info_t *loc, mode_t mode)
 Change the IMFS file mode.
 
int IMFS_symlink (const rtems_filesystem_location_info_t *parentloc, const char *name, size_t namelen, const char *target)
 Create a new IMFS symbolic link node. More...
 
ssize_t IMFS_readlink (const rtems_filesystem_location_info_t *loc, char *buf, size_t bufsize)
 Put IMFS symbolic link into buffer. More...
 
int IMFS_rename (const rtems_filesystem_location_info_t *oldparentloc, const rtems_filesystem_location_info_t *oldloc, const rtems_filesystem_location_info_t *newparentloc, const char *name, size_t namelen)
 Rename the IMFS. More...
 
int IMFS_rmnod (const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *loc)
 IMFS node removal handler. More...
 

Variables

int imfs_rq_memfile_bytes_per_block
 
int imfs_memfile_bytes_per_block
 
const IMFS_mknod_control IMFS_mknod_control_dir_default
 
const IMFS_mknod_control IMFS_mknod_control_dir_minimal
 
const IMFS_mknod_control IMFS_mknod_control_device
 
const IMFS_mknod_control IMFS_mknod_control_memfile
 
const IMFS_node_control IMFS_node_control_linfile
 
const IMFS_mknod_control IMFS_mknod_control_fifo
 
const IMFS_mknod_control IMFS_mknod_control_enosys
 
const rtems_filesystem_limits_and_options_t IMFS_LIMITS_AND_OPTIONS
 

IMFS Memory File Handlers

This section contains the set of handlers used to process operations on IMFS memory file nodes. The memory files are created in memory using malloc'ed memory. Thus any data stored in one of these files is lost at system shutdown unless special arrangements to copy the data to some type of non-volailte storage are made by the application.

ssize_t IMFS_memfile_write (IMFS_memfile_t *memfile, off_t start, const unsigned char *source, unsigned int length)
 

IMFS Device Node Handlers

This section contains the set of handlers used to map operations on IMFS device nodes onto calls to the RTEMS Classic API IO Manager.

int device_open (rtems_libio_t *iop, const char *pathname, int oflag, mode_t mode)
 
int device_close (rtems_libio_t *iop)
 
ssize_t device_read (rtems_libio_t *iop, void *buffer, size_t count)
 
ssize_t device_write (rtems_libio_t *iop, const void *buffer, size_t count)
 
int device_ioctl (rtems_libio_t *iop, ioctl_command_t command, void *buffer)
 
int device_ftruncate (rtems_libio_t *iop, off_t length)
 

Detailed Description

In-Memory File System Support.

Macro Definition Documentation

◆ IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK

#define IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK   128

IMFS "memfile" information

The data structure for the in-memory "memfiles" is based on classic UNIX.

block_ptr is a pointer to a block of IMFS_MEMFILE_BYTES_PER_BLOCK in length which could be data or a table of pointers to blocks.

Setting IMFS_MEMFILE_BYTES_PER_BLOCK to different values has a significant impact on the maximum file size supported as well as the amount of memory wasted due to internal file fragmentation. The following is a list of maximum file sizes based on various settings

max_filesize with blocks of 16 is 1,328
max_filesize with blocks of 32 is 18,656
max_filesize with blocks of 64 is 279,488
max_filesize with blocks of 128 is 4,329,344
max_filesize with blocks of 256 is 68,173,568
max_filesize with blocks of 512 is 1,082,195,456

◆ LAST_DOUBLY_INDIRECT

#define LAST_DOUBLY_INDIRECT
Value:
(LAST_INDIRECT + \
(IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS))

◆ LAST_TRIPLY_INDIRECT

#define LAST_TRIPLY_INDIRECT
Value:
(LAST_DOUBLY_INDIRECT +\
(IMFS_MEMFILE_BLOCK_SLOTS * \
IMFS_MEMFILE_BLOCK_SLOTS * IMFS_MEMFILE_BLOCK_SLOTS))

Function Documentation

◆ IMFS_chown()

int IMFS_chown ( const rtems_filesystem_location_info_t loc,
uid_t  owner,
gid_t  group 
)

Change the owner of IMFS.

This routine is the implementation of the chown() system call for the IMFS.

◆ IMFS_create_node()

IMFS_jnode_t* IMFS_create_node ( const rtems_filesystem_location_info_t parentloc,
const IMFS_node_control node_control,
size_t  node_size,
const char *  name,
size_t  namelen,
mode_t  mode,
void *  arg 
)

Create an IMFS node.

Create an IMFS filesystem node of an arbitrary type that is NOT the root directory node.

◆ IMFS_link()

int IMFS_link ( const rtems_filesystem_location_info_t parentloc,
const rtems_filesystem_location_info_t targetloc,
const char *  name,
size_t  namelen 
)

Create a new IMFS link node.

The following rouine creates a new link node under parent with the name given in name. The link node is set to point to the node at to_loc.

◆ IMFS_mknod()

int IMFS_mknod ( const rtems_filesystem_location_info_t parentloc,
const char *  name,
size_t  namelen,
mode_t  mode,
dev_t  dev 
)

Create an IMFS node.

Routine to create a node in the IMFS file system.

◆ IMFS_readlink()

ssize_t IMFS_readlink ( const rtems_filesystem_location_info_t loc,
char *  buf,
size_t  bufsize 
)

Put IMFS symbolic link into buffer.

The following rouine puts the symbolic links destination name into buff.

◆ IMFS_rename()

int IMFS_rename ( const rtems_filesystem_location_info_t oldparentloc,
const rtems_filesystem_location_info_t oldloc,
const rtems_filesystem_location_info_t newparentloc,
const char *  name,
size_t  namelen 
)

Rename the IMFS.

The following rouine creates a new link node under parent with the name given in name and removes the old.

◆ IMFS_rmnod()

int IMFS_rmnod ( const rtems_filesystem_location_info_t parentloc,
const rtems_filesystem_location_info_t loc 
)

IMFS node removal handler.

This file contains the handler used to remove a node when a file type does not require special actions.

◆ IMFS_stat()

int IMFS_stat ( const rtems_filesystem_location_info_t loc,
struct stat *  buf 
)

Perform a status processing for the IMFS.

This routine provides a stat for the IMFS file system.

◆ IMFS_symlink()

int IMFS_symlink ( const rtems_filesystem_location_info_t parentloc,
const char *  name,
size_t  namelen,
const char *  target 
)

Create a new IMFS symbolic link node.

The following rouine creates a new symbolic link node under parent with the name given in name. The node is set to point to the node at to_loc.

◆ IMFS_utime()

int IMFS_utime ( const rtems_filesystem_location_info_t loc,
time_t  actime,
time_t  modtime 
)

Set IMFS file access and modification times.

This routine is the implementation of the utime() system call for the IMFS.

◆ rtems_tarfs_load()

int rtems_tarfs_load ( const char *  mountpoint,
uint8_t *  tar_image,
size_t  tar_size 
)

RTEMS load tarfs.

This file implements the "mount" procedure for tar-based IMFS extensions. The TAR is not actually mounted under the IMFS. Directories from the TAR file are created as usual in the IMFS. File entries are created as IMFS_LINEAR_FILE nodes with their nods pointing to addresses in the TAR image.

Here we create the mountpoint directory and load the tarfs at that node. Once the IMFS has been mounted, we work through the tar image and perform as follows:

  • For directories, simply call mkdir(). The IMFS creates nodes as needed.
  • For files, we make our own calls to IMFS eval_for_make and create_node.

TAR file format:

Offset Length Contents
0 100 bytes File name ('\0' terminated, 99 maxmum length)
100 8 bytes File mode (in octal ascii)
108 8 bytes User ID (in octal ascii)
116 8 bytes Group ID (in octal ascii)
124 12 bytes File size (s) (in octal ascii)
136 12 bytes Modify time (in octal ascii)
148 8 bytes Header checksum (in octal ascii)
156 1 bytes Link flag
157 100 bytes Linkname ('\0' terminated, 99 maxmum length)
257 8 bytes Magic PAX ("ustar\0" + 2 bytes padding)
257 8 bytes Magic GNU tar ("ustar \0")
265 32 bytes User name ('\0' terminated, 31 maxmum length)
297 32 bytes Group name ('\0' terminated, 31 maxmum length)
329 8 bytes Major device ID (in octal ascii)
337 8 bytes Minor device ID (in octal ascii)
345 167 bytes Padding
512 (s+p) bytes File contents (s+p) := (((s) + 511) & ~511),
round up to 512 bytes

Checksum:

int i, sum;
char *header = tar_header_pointer;
sum = 0;
for (i = 0; i < 512; i++)
sum += 0xFF & header[i];