source: rtems/cpukit/libfs/src/imfs/imfs_creat.c @ a43a3466

4.115
Last change on this file since a43a3466 was a43a3466, checked in by Sebastian Huber <sebastian.huber@…>, on 02/15/15 at 09:38:15

IMFS: Implement variable length node names

This reduces the average node size and adds more flexibility.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief Create an IMFS Node
5 * @ingroup IMFS
6 */
7/*
8 *  COPYRIGHT (c) 1989-2010.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#if HAVE_CONFIG_H
17  #include "config.h"
18#endif
19
20#include "imfs.h"
21
22#include <stdlib.h>
23#include <string.h>
24
25IMFS_jnode_t *IMFS_create_node(
26  const rtems_filesystem_location_info_t *parentloc,
27  const IMFS_node_control *node_control,
28  size_t node_size,
29  const char *name,
30  size_t namelen,
31  mode_t mode,
32  void *arg
33)
34{
35  IMFS_jnode_t *allocated_node;
36  IMFS_jnode_t *node;
37
38  allocated_node = calloc( 1, node_size + namelen );
39  if ( allocated_node == NULL ) {
40    errno = ENOMEM;
41
42    return NULL;
43  }
44
45  node = IMFS_initialize_node(
46    allocated_node,
47    node_control,
48    (char *) allocated_node + node_size,
49    namelen,
50    mode,
51    arg
52  );
53  if ( node != NULL ) {
54    IMFS_jnode_t *parent = parentloc->node_access;
55
56    memcpy( node->name, name, namelen );
57
58    /*
59     *  This node MUST have a parent, so put it in that directory list.
60     */
61    IMFS_assert( parent != NULL );
62    IMFS_add_to_directory( parent, node );
63  } else {
64    free( allocated_node );
65  }
66
67  return node;
68}
69
Note: See TracBrowser for help on using the repository browser.