RTEMS: IMFS Generic Nodes

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions
IMFS Generic Nodes
IO Library

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.
#define | IMFS_GENERIC_NODE_INITIALIZER(node_control, name, namelen, mode) { IMFS_NODE_INITIALIZER( node_control, name, namelen, mode ), NULL }
| Initializer for a generic node.

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

## Functions
IMFS_jnode_t * | IMFS_node_initialize_default (IMFS_jnode_t *node, void *arg)
| Returns the node and does nothing else.
IMFS_jnode_t * | IMFS_node_initialize_directory (IMFS_jnode_t *node, void *arg)
IMFS_jnode_t * | IMFS_node_initialize_generic (IMFS_jnode_t *node, void *arg)
| Returns the node and sets the generic node context.
IMFS_jnode_t * | IMFS_node_remove_default (IMFS_jnode_t *node)
| Returns the node and does nothing else.
IMFS_jnode_t * | IMFS_node_remove_directory (IMFS_jnode_t *node)
void | IMFS_node_destroy_default (IMFS_jnode_t *node)
| Frees the node.
void | IMFS_do_nothing_destroy (IMFS_jnode_t *node)
| Does nothing.
int | IMFS_make_generic_node (const char *path, mode_t mode, const IMFS_node_control *node_control, void *context)
| Makes a generic IMFS node.

## 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

  handlers | The file system node handlers.
  init | The node initialization method.
  destroy | The 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_control | The node control of the IMFS generic node.
  name | The name of the IMFS generic node.
  namelen | The length of the name of the IMFS generic node.
  mode | The 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] | node | The 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] | node | The IMFS node.
  [in] | arg | The user provided argument pointer. It may contain node specific initialization information.

Return values

  node | Successful operation.
  NULL | An 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] | node | The IMFS node.

Return values

  node | Successful operation.
  NULL | An 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

  node | The 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] | path | The path to the new generic IMFS node.
  [in] | mode | The node mode.
  [in] | node_control | The node control.
  [in] | context | The node control handler context.

Return values

  0 | Successful operation.
  -1 | An 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);
IMFS_node_destroy_default(node);
}
static const IMFS_node_control
some_node_control = IMFS_GENERIC_CONTROL_INITIALIZER(
&some_node_handlers,
some_node_init,
some_node_destroy
);
void example(void *some_node_context)
{
int rv;
rv = IMFS_make_generic_node(
"/path/to/some/generic/node",
S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
&some_node_control,
some_node_context
);
assert(rv == 0);
}
assert.h
Information for the Assert Handler.
IMFS_GENERIC_CONTROL_INITIALIZER
#define IMFS_GENERIC_CONTROL_INITIALIZER(handlers, init, destroy)
Initializer for a generic node control.
Definition: imfs.h:758
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.
Definition: imfs_make_generic_node.c:31
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.
Definition: imfs_make_generic_node.c:43
IMFS_node_destroy_default
void IMFS_node_destroy_default(IMFS_jnode_t *node)
Frees the node.
Definition: imfs_node_destroy_default.c:44
imfs.h
Header File for the In-Memory File System.
IMFS_jnode_tt
Definition: imfs.h:250
IMFS_node_control
IMFS node control.
Definition: imfs.h:220
_rtems_filesystem_file_handlers_r
File system node operations table.
Definition: libio.h:1005

## ◆ IMFS_node_destroy_default()

void IMFS_node_destroy_default | ( | IMFS_jnode_t * | node | ) |

Frees the node.

Parameters

  [in] | node | The 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] | node | The IMFS node.
  [in] | arg | The user provided argument pointer. It is not used.

Return values

  node | Returns 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] | node | The IMFS node.
  [in] | arg | The user provided argument pointer. It must contain the generic context.

Return values

  node | Returns 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] | node | The IMFS node.

Return values

  node | Returns always the node passed as parameter.

See also
  IMFS_node_control.