source: rtems/cpukit/libcsupport/src/base_fs.c @ a29d2e7

4.104.114.84.95
Last change on this file since a29d2e7 was 50f32b11, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/18/04 at 06:05:35

Remove stray white spaces.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  Base file system initialization
3 *
4 *  COPYRIGHT (c) 1989-1999.
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 <rtems.h>
19#include <rtems/libio.h>
20#include <rtems/libio_.h>
21
22/*
23 *  Global information for the base file system.
24 */
25
26rtems_user_env_t   rtems_global_user_env;
27rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
28
29/*
30 *  Default mode for created files.
31 */
32
33
34/*
35 *  rtems_filesystem_initialize
36 *
37 *  Initialize the foundation of the file system.  This is specified
38 *  by the structure rtems_filesystem_mount_table.  The usual
39 *  configuration is a single instantiation of the IMFS or miniIMFS with
40 *  a single "/dev" directory in it.
41 */
42
43void rtems_filesystem_initialize( void )
44{
45#if !defined(RTEMS_UNIX)
46#if 0
47  int                                   i;
48#endif
49  int                                   status;
50  rtems_filesystem_mount_table_entry_t *entry;
51  rtems_filesystem_mount_table_t       *mt;
52  rtems_filesystem_location_info_t              loc;
53
54  /*
55   *  Set the default umask to "022".
56   */
57
58  rtems_filesystem_umask = 022;
59
60
61  init_fs_mount_table();
62
63  /*
64   *  mount the first filesystem.
65   */
66
67  if ( rtems_filesystem_mount_table_size == 0 )
68    rtems_fatal_error_occurred( 0xABCD0001 );
69
70  mt = &rtems_filesystem_mount_table[0];
71
72  status = mount(
73     &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
74
75  if ( status == -1 )
76    rtems_fatal_error_occurred( 0xABCD0002 );
77
78  rtems_filesystem_link_counts = 0;
79
80  /* setup the 'current' and 'root' directories
81   *
82   * NOTE: cloning the pathlocs is not strictly
83   *       necessary. Since we implicitely let
84   *       all threads that don't call
85   *       libio_set_private_env() share the same
86   *       (initial) 'root' and 'current' locs,
87   *       we (also implicitely) assume that the
88   *       root filesystem doesn't care about
89   *       reference counts.
90   *       I just inserted the code snippet below
91   *       to remind everybody of the fact by
92   *       making it more explicit...
93   *       Ideally, every thread would have to
94   *       call either share_private_env() or
95   *       set_private_env() - but then: that's
96   *       gonna hit performance.
97   *
98   *       Till Straumann, 10/25/2002
99   */
100  rtems_filesystem_root        = entry->mt_fs_root;
101  /* Clone the root pathloc */
102  rtems_filesystem_evaluate_path("/", 0, &loc, 0);
103  rtems_filesystem_root        = loc;
104  /* One more clone for the current node */
105  rtems_filesystem_evaluate_path("/", 0, &loc, 0);
106  rtems_filesystem_current     = loc;
107
108  /* Note: the global_env's refcnt doesn't matter
109   * as the global env is never released
110   */
111
112
113  /*
114   *  Traditionally RTEMS devices are under "/dev" so install this directory.
115   *
116   *  If the mkdir() fails, we can't print anything so just fatal error.
117   *
118   *  NOTE: UNIX root is 755 and owned by root/root (0/0).  It is actually
119   *        created that way by the IMFS.
120   */
121
122  status = mkdir( "/dev", 0777);
123  if ( status != 0 )
124    rtems_fatal_error_occurred( 0xABCD0003 );
125
126  /*
127   *  This code if if'ed 0 out because you can't mount another
128   *  filesystem properly until the mount point it will be
129   *  mounted onto is created.  Moreover, if it is going to
130   *  use a device, then it is REALLY unfair to attempt this
131   *  before device drivers are initialized.
132   */
133
134#if 0
135  /*
136   *  Now if there are other filesystems to mount, go for it.
137   */
138
139  for ( i=1 ; i < rtems_filesystem_mount_table_size ; i++ ) {
140    mt = &rtems_filesystem_mount_table[0];
141
142    status = mount(
143       &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
144
145    if ( status == -1 )
146      rtems_fatal_error_occurred( 0xABCD0003 );
147  }
148#endif
149#endif
150}
Note: See TracBrowser for help on using the repository browser.