RTEMS  5.0.0
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)
 Initializer for a generic node control. 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...
 
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_INITIALIZER

#define IMFS_GENERIC_INITIALIZER (   handlers,
  init,
  destroy 
)
Value:
{ \
( handlers ), \
( init ), \
IMFS_node_remove_default, \
( destroy ) \
}

Initializer for a generic node control.

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

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_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_control = IMFS_GENERIC_INITIALIZER(
&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);
}

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