RTEMS 6.1-rc1
Data Structures | Macros | Typedefs | Functions
IMFS Generic Nodes

Generic nodes are an alternative to standard drivers in RTEMS. More...

Data Structures

struct  IMFS_node_control
 IMFS node control. More...
 
struct  IMFS_mknod_control
 

Macros

#define IMFS_GENERIC_INITIALIZER(handlers, init, destroy)    IMFS_NODE_CONTROL_INITIALIZER( handlers, init, destroy )
 
#define IMFS_GENERIC_CONTROL_INITIALIZER(handlers, init, destroy)    IMFS_NODE_CONTROL_INITIALIZER( handlers, init, destroy )
 Initializer for a generic node control. More...
 
#define IMFS_GENERIC_NODE_INITIALIZER(node_control, name, namelen, mode)    { IMFS_NODE_INITIALIZER( node_control, name, namelen, mode ), NULL }
 Initializer for a generic node. More...
 

Typedefs

typedef IMFS_jnode_t *(* IMFS_node_control_initialize) (IMFS_jnode_t *node, void *arg)
 Initializes an IMFS node. More...
 
typedef IMFS_jnode_t *(* IMFS_node_control_remove) (IMFS_jnode_t *node)
 Prepares the removal of an IMFS node from its parent directory. More...
 
typedef void(* IMFS_node_control_destroy) (IMFS_jnode_t *node)
 Destroys an IMFS node. More...
 

Functions

IMFS_jnode_tIMFS_node_initialize_default (IMFS_jnode_t *node, void *arg)
 Returns the node and does nothing else. More...
 
IMFS_jnode_tIMFS_node_initialize_directory (IMFS_jnode_t *node, void *arg)
 
IMFS_jnode_tIMFS_node_initialize_generic (IMFS_jnode_t *node, void *arg)
 Returns the node and sets the generic node context. More...
 
IMFS_jnode_tIMFS_node_remove_default (IMFS_jnode_t *node)
 Returns the node and does nothing else. More...
 
IMFS_jnode_tIMFS_node_remove_directory (IMFS_jnode_t *node)
 
void IMFS_node_destroy_default (IMFS_jnode_t *node)
 Frees the node. More...
 
void IMFS_do_nothing_destroy (IMFS_jnode_t *node)
 Does nothing. More...
 
int IMFS_make_generic_node (const char *path, mode_t mode, const IMFS_node_control *node_control, void *context)
 Makes a generic IMFS node. More...
 

Detailed Description

Generic nodes are an alternative to standard drivers in RTEMS.

The handlers of a generic node are called with less overhead compared to the standard driver operations. The usage of file system node handlers enable more features like support for fsync() and fdatasync(). The generic nodes use the reference counting of the IMFS. This provides automatic node destruction when the last reference vanishes.

Macro Definition Documentation

◆ IMFS_GENERIC_CONTROL_INITIALIZER

#define IMFS_GENERIC_CONTROL_INITIALIZER (   handlers,
  init,
  destroy 
)     IMFS_NODE_CONTROL_INITIALIZER( handlers, init, destroy )

Initializer for a generic node control.

Parameters
handlersThe file system node handlers.
initThe node initialization method.
destroyThe node destruction method.

◆ IMFS_GENERIC_NODE_INITIALIZER

#define IMFS_GENERIC_NODE_INITIALIZER (   node_control,
  name,
  namelen,
  mode 
)     { IMFS_NODE_INITIALIZER( node_control, name, namelen, mode ), NULL }

Initializer for a generic node.

Initialize the node control with IMFS_GENERIC_CONTROL_INITIALIZER().

Parameters
node_controlThe node control of the IMFS generic node.
nameThe name of the IMFS generic node.
namelenThe length of the name of the IMFS generic node.
modeThe mode of the IMFS generic node.

Typedef Documentation

◆ IMFS_node_control_destroy

typedef void(* IMFS_node_control_destroy) (IMFS_jnode_t *node)

Destroys an IMFS node.

Parameters
[in]nodeThe IMFS node.
See also
IMFS_node_control and IMFS_node_destroy_default().

◆ IMFS_node_control_initialize

typedef IMFS_jnode_t *(* IMFS_node_control_initialize) (IMFS_jnode_t *node, void *arg)

Initializes an IMFS node.

Parameters
[in]nodeThe IMFS node.
[in]argThe user provided argument pointer. It may contain node specific initialization information.
Return values
nodeSuccessful operation.
NULLAn error occurred. The errno indicates the error. This will abort the make operation.
See also
IMFS_node_control, IMFS_node_initialize_default(), and IMFS_node_initialize_generic().

◆ IMFS_node_control_remove

typedef IMFS_jnode_t *(* IMFS_node_control_remove) (IMFS_jnode_t *node)

Prepares the removal of an IMFS node from its parent directory.

Parameters
[in]nodeThe IMFS node.
Return values
nodeSuccessful operation.
NULLAn error occurred. The errno indicates the error. This will abort the removal operation.
See also
IMFS_node_control and IMFS_node_remove_default().

Function Documentation

◆ IMFS_do_nothing_destroy()

void IMFS_do_nothing_destroy ( IMFS_jnode_t node)

Does nothing.

Parameters
nodeThe IMFS node.
See also
IMFS_node_control.

◆ IMFS_make_generic_node()

int IMFS_make_generic_node ( const char *  path,
mode_t  mode,
const IMFS_node_control node_control,
void *  context 
)

Makes a generic IMFS node.

Parameters
[in]pathThe path to the new generic IMFS node.
[in]modeThe node mode.
[in]node_controlThe node control.
[in]contextThe node control handler context.
Return values
0Successful operation.
-1An error occurred. The errno indicates the error.
#include <sys/stat.h>
#include <assert.h>
#include <fcntl.h>
#include <rtems/imfs.h>
static const rtems_filesystem_file_handlers_r some_node_handlers = {
...
};
static IMFS_jnode_t *some_node_init(IMFS_jnode_t *node, void *arg)
{
void *context;
node = IMFS_node_initialize_generic(node, arg);
context = IMFS_generic_get_context_by_node(node);
return node;
}
static void some_node_destroy(IMFS_jnode_t *node)
{
void *context = IMFS_generic_get_context_by_node(node);
}
static const IMFS_node_control
&some_node_handlers,
some_node_init,
some_node_destroy
);
void example(void *some_node_context)
{
int rv;
"/path/to/some/generic/node",
S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
&some_node_control,
some_node_context
);
assert(rv == 0);
}
This header file provides the interfaces of the Assert Handler.
#define IMFS_GENERIC_CONTROL_INITIALIZER(handlers, init, destroy)
Initializer for a generic node control.
Definition: imfs.h:740
IMFS_jnode_t * IMFS_node_initialize_generic(IMFS_jnode_t *node, void *arg)
Returns the node and sets the generic node context.
Definition: imfs_make_generic_node.c:44
int IMFS_make_generic_node(const char *path, mode_t mode, const IMFS_node_control *node_control, void *context)
Makes a generic IMFS node.
Definition: imfs_make_generic_node.c:56
void IMFS_node_destroy_default(IMFS_jnode_t *node)
Frees the node.
Definition: imfs_node_destroy_default.c:44
This header file defines the API of the In-Memory File System.
rtems_termios_device_context * context
Definition: console-config.c:62
Definition: imfs.h:267
IMFS node control.
Definition: imfs.h:237
File system node operations table.
Definition: libio.h:1020

◆ IMFS_node_destroy_default()

void IMFS_node_destroy_default ( IMFS_jnode_t node)

Frees the node.

Parameters
[in]nodeThe IMFS node.
See also
IMFS_node_control.

◆ IMFS_node_initialize_default()

IMFS_jnode_t * IMFS_node_initialize_default ( IMFS_jnode_t node,
void *  arg 
)

Returns the node and does nothing else.

Parameters
[in]nodeThe IMFS node.
[in]argThe user provided argument pointer. It is not used.
Return values
nodeReturns always the node passed as parameter.
See also
IMFS_node_control.

◆ IMFS_node_initialize_generic()

IMFS_jnode_t * IMFS_node_initialize_generic ( IMFS_jnode_t node,
void *  arg 
)

Returns the node and sets the generic node context.

Parameters
[in]nodeThe IMFS node.
[in]argThe user provided argument pointer. It must contain the generic context.
Return values
nodeReturns always the node passed as parameter.
See also
IMFS_node_control.

◆ IMFS_node_remove_default()

IMFS_jnode_t * IMFS_node_remove_default ( IMFS_jnode_t node)

Returns the node and does nothing else.

Parameters
[in]nodeThe IMFS node.
Return values
nodeReturns always the node passed as parameter.
See also
IMFS_node_control.