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

4.104.115
Last change on this file since cb4e992 was cb4e992, checked in by Joel Sherrill <joel.sherrill@…>, on 01/19/10 at 19:31:00

2010-01-19 Joel Sherrill <joel.sherrill@…>

  • libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_initsupp.c, libfs/src/imfs/imfs_link.c, libfs/src/imfs/imfs_load_tar.c, libfs/src/imfs/imfs_mknod.c, libfs/src/imfs/imfs_symlink.c: Create special helper method for creating the j-node for the root directory. This lets us assume that every j-node created otherwise has a parent node.
  • Property mode set to 100644
File size: 2.7 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)
71{
72  IMFS_fs_info_t                        *fs_info;
73  IMFS_jnode_t                          *jnode;
74
75  /*
76   * determine/check value for imfs_memfile_bytes_per_block
77   */
78  IMFS_determine_bytes_per_block(&imfs_memfile_bytes_per_block,
79                                 imfs_rq_memfile_bytes_per_block,
80                                 IMFS_MEMFILE_DEFAULT_BYTES_PER_BLOCK);
81
82  /*
83   *  Create the root node
84   *
85   *  NOTE: UNIX root is 755 and owned by root/root (0/0).
86   */
87  temp_mt_entry->mt_fs_root.node_access      = IMFS_create_root_node();
88  temp_mt_entry->mt_fs_root.handlers         = directory_handlers;
89  temp_mt_entry->mt_fs_root.ops              = op_table;
90  temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS;
91
92  /*
93   * Create custom file system data.
94   */
95  fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) );
96  if ( !fs_info ) {
97    free(temp_mt_entry->mt_fs_root.node_access);
98    rtems_set_errno_and_return_minus_one(ENOMEM);
99  }
100  temp_mt_entry->fs_info = fs_info;
101
102  /*
103   * Set st_ino for the root to 1.
104   */
105
106  fs_info->ino_count             = 1;
107  fs_info->memfile_handlers      = memfile_handlers;
108  fs_info->directory_handlers    = directory_handlers;
109
110  jnode = temp_mt_entry->mt_fs_root.node_access;
111  jnode->st_ino = fs_info->ino_count;
112
113  /* Initialize POSIX FIFO/pipe module */
114  rtems_pipe_initialize();
115
116  return 0;
117}
Note: See TracBrowser for help on using the repository browser.