source: rtems/cpukit/libfs/src/imfs/imfs_initsupp.c @ 241f4c96

4.115
Last change on this file since 241f4c96 was 241f4c96, checked in by Sebastian Huber <sebastian.huber@…>, on 06/08/10 at 10:25:46

2010-06-08 Sebastian Huber <sebastian.huber@…>

  • libfs/src/imfs/fifoimfs_init.c: New file.
  • libfs/Makefile.am: Reflect change above.
  • libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c, libfs/src/imfs/imfs_initsupp.c, libfs/src/imfs/miniimfs_init.c, libfs/src/pipe/fifo.c, libfs/src/pipe/pipe.c, libfs/src/pipe/pipe.h: Pipe support is now link-time optional.
  • sapi/include/confdefs.h: Reflect changes above.
  • Property mode set to 100644
File size: 2.9 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 *  $Id$
12 */
13
14#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <sys/types.h>         /* for mkdir */
19#include <fcntl.h>
20#include <unistd.h>
21#include <stdlib.h>
22
23#include <assert.h>
24
25#include "imfs.h"
26#include <rtems/libio_.h>
27#include <rtems/seterr.h>
28
29#if defined(IMFS_DEBUG)
30#include <stdio.h>
31#endif
32
33/*
34 *  IMFS_determine_bytes_per_block
35 */
36int imfs_memfile_bytes_per_block = 0;
37
38static int IMFS_determine_bytes_per_block(
39  int *dest_bytes_per_block,
40  int requested_bytes_per_block,
41  int default_bytes_per_block
42)
43{
44  bool is_valid = false;
45  int bit_mask;
46
47  /*
48   * check, whether requested bytes per block is valid
49   */
50  for (bit_mask = 16; !is_valid && (bit_mask <= 512); bit_mask <<= 1) {
51    if (bit_mask == requested_bytes_per_block) {
52      is_valid = true;
53    }
54  }
55  *dest_bytes_per_block = ((is_valid)
56                           ? requested_bytes_per_block
57                           : default_bytes_per_block);
58  return 0;
59}
60
61
62/*
63 *  IMFS_initialize
64 */
65int IMFS_initialize_support(
66  rtems_filesystem_mount_table_entry_t        *temp_mt_entry,
67   const rtems_filesystem_operations_table    *op_table,
68   const rtems_filesystem_file_handlers_r     *memfile_handlers,
69   const rtems_filesystem_file_handlers_r     *directory_handlers,
70   const rtems_filesystem_file_handlers_r     *fifo_handlers
71)
72{
73  static int                             imfs_instance;
74  IMFS_fs_info_t                        *fs_info;
75  IMFS_jnode_t                          *jnode;
76
77  /*
78   * determine/check value for imfs_memfile_bytes_per_block
79   */
80  IMFS_determine_bytes_per_block(&imfs_memfile_bytes_per_block,
81                                 imfs_rq_memfile_bytes_per_block,
82                                 IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK);
83
84  /*
85   *  Create the root node
86   *
87   *  NOTE: UNIX root is 755 and owned by root/root (0/0).
88   */
89  temp_mt_entry->mt_fs_root.node_access      = IMFS_create_root_node();
90  temp_mt_entry->mt_fs_root.handlers         = directory_handlers;
91  temp_mt_entry->mt_fs_root.ops              = op_table;
92  temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
93
94  /*
95   * Create custom file system data.
96   */
97  fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) );
98  if ( !fs_info ) {
99    free(temp_mt_entry->mt_fs_root.node_access);
100    rtems_set_errno_and_return_minus_one(ENOMEM);
101  }
102  temp_mt_entry->fs_info = fs_info;
103
104  /*
105   * Set st_ino for the root to 1.
106   */
107
108  fs_info->instance              = imfs_instance++;
109  fs_info->ino_count             = 1;
110  fs_info->memfile_handlers      = memfile_handlers;
111  fs_info->directory_handlers    = directory_handlers;
112  fs_info->fifo_handlers         = fifo_handlers;
113
114  jnode = temp_mt_entry->mt_fs_root.node_access;
115  jnode->st_ino = fs_info->ino_count;
116
117  return 0;
118}
Note: See TracBrowser for help on using the repository browser.