source: rtems/cpukit/libfs/src/imfs/imfs_initsupp.c @ 9b4422a2

4.11
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on May 3, 2012 at 3:09:24 PM

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

  • Property mode set to 100644
File size: 3.4 KB
Line 
1/*
2 *  IMFS Initialization
3 *
4 *  COPYRIGHT (c) 1989-2010.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 */
11
12#if HAVE_CONFIG_H
13  #include "config.h"
14#endif
15
16#include "imfs.h"
17
18#include <stdlib.h>
19
20/*
21 *  IMFS_determine_bytes_per_block
22 */
23int imfs_memfile_bytes_per_block = 0;
24
25static int IMFS_determine_bytes_per_block(
26  int *dest_bytes_per_block,
27  int requested_bytes_per_block,
28  int default_bytes_per_block
29)
30{
31  bool is_valid = false;
32  int bit_mask;
33
34  /*
35   * check, whether requested bytes per block is valid
36   */
37  for (bit_mask = 16; !is_valid && (bit_mask <= 512); bit_mask <<= 1) {
38    if (bit_mask == requested_bytes_per_block) {
39      is_valid = true;
40      break;
41    }
42    if(bit_mask > requested_bytes_per_block)
43      break;
44  }
45  *dest_bytes_per_block = ((is_valid)
46                           ? requested_bytes_per_block
47                           : default_bytes_per_block);
48  return 0;
49}
50
51int IMFS_initialize_support(
52  rtems_filesystem_mount_table_entry_t *mt_entry,
53  const rtems_filesystem_operations_table *op_table,
54  const IMFS_node_control *const node_controls [IMFS_TYPE_COUNT]
55)
56{
57  static int imfs_instance;
58
59  int rv = 0;
60  IMFS_fs_info_t *fs_info = calloc( 1, sizeof( *fs_info ) );
61
62  if ( fs_info != NULL ) {
63    IMFS_jnode_t *root_node;
64
65    fs_info->instance = imfs_instance++;
66    memcpy(
67      fs_info->node_controls,
68      node_controls,
69      sizeof( fs_info->node_controls )
70    );
71
72    root_node = IMFS_allocate_node(
73      fs_info,
74      fs_info->node_controls [IMFS_DIRECTORY],
75      "",
76      0,
77      (S_IFDIR | 0755),
78      NULL
79    );
80    if ( root_node != NULL ) {
81      mt_entry->fs_info = fs_info;
82      mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
83      mt_entry->mt_fs_root->location.node_access = root_node;
84      mt_entry->mt_fs_root->location.ops = op_table;
85      IMFS_Set_handlers( &mt_entry->mt_fs_root->location );
86    } else {
87      errno = ENOMEM;
88      rv = -1;
89    }
90  } else {
91    errno = ENOMEM;
92    rv = -1;
93  }
94
95  if ( rv == 0 ) {
96    IMFS_determine_bytes_per_block(
97      &imfs_memfile_bytes_per_block,
98      imfs_rq_memfile_bytes_per_block,
99      IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK
100    );
101  }
102
103  return rv;
104}
105
106int IMFS_node_clone( rtems_filesystem_location_info_t *loc )
107{
108  IMFS_jnode_t *node = loc->node_access;
109
110  ++node->reference_count;
111
112  return 0;
113}
114
115void IMFS_node_destroy( IMFS_jnode_t *node )
116{
117  IMFS_assert( node->reference_count == 0 );
118
119  node = (*node->control->node_destroy)( node );
120
121  free( node );
122}
123
124void IMFS_node_free( const rtems_filesystem_location_info_t *loc )
125{
126  IMFS_jnode_t *node = loc->node_access;
127
128  if ( node->reference_count == 1 ) {
129    IMFS_node_destroy( node );
130  } else {
131    --node->reference_count;
132  }
133}
134
135IMFS_jnode_t *IMFS_node_initialize_default(
136  IMFS_jnode_t *node,
137  const IMFS_types_union *info
138)
139{
140  return node;
141}
142
143IMFS_jnode_t *IMFS_node_remove_default(
144  IMFS_jnode_t *node,
145  const IMFS_jnode_t *root_node
146)
147{
148  return node;
149}
150
151IMFS_jnode_t *IMFS_node_destroy_default( IMFS_jnode_t *node )
152{
153  return node;
154}
155
156const IMFS_node_control IMFS_node_control_default = {
157  .imfs_type = IMFS_INVALID_NODE,
158  .handlers = &rtems_filesystem_handlers_default,
159  .node_initialize = IMFS_node_initialize_default,
160  .node_remove = IMFS_node_remove_default,
161  .node_destroy = IMFS_node_destroy_default
162};
Note: See TracBrowser for help on using the repository browser.