source: rtems/cpukit/libcsupport/src/base_fs.c @ 2d08be1

4.115
Last change on this file since 2d08be1 was 2d08be1, checked in by Joel Sherrill <joel.sherrill@…>, on 08/02/10 at 18:24:15

2010-08-02 Joel Sherrill <joel.sherrill@…>

  • libcsupport/src/base_fs.c, libcsupport/src/rtems_mkdir.c: Formatting.
  • Property mode set to 100644
File size: 3.2 KB
Line 
1/*
2 *  Base file system initialization
3 *
4 *  COPYRIGHT (c) 1989-2008.
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 *  Default mode for created files.
24 */
25
26
27/*
28 *  rtems_filesystem_initialize
29 *
30 *  Initialize the foundation of the file system.  This is specified
31 *  by the structure rtems_filesystem_mount_table.  The usual
32 *  configuration is a single instantiation of the IMFS or miniIMFS with
33 *  a single "/dev" directory in it.
34 */
35
36void rtems_filesystem_initialize( void )
37{
38  int                                   status;
39  const rtems_filesystem_mount_table_t *mt;
40  rtems_filesystem_location_info_t      loc;
41
42  /*
43   *  Set the default umask to "022".
44   */
45
46  rtems_filesystem_umask = 022;
47
48  /*
49   *  mount the first filesystem.
50   */
51  if ( rtems_filesystem_mount_table_size == 0 )
52    rtems_fatal_error_occurred( 0xABCD0001 );
53
54  mt = &rtems_filesystem_mount_table[0];
55
56  status = mount( mt->device, mt->mount_point, mt->type, mt->fsoptions, NULL );
57  if ( status == -1 )
58    rtems_fatal_error_occurred( 0xABCD0002 );
59
60  rtems_filesystem_link_counts = 0;
61
62  /* setup the 'current' and 'root' directories
63   *
64   * NOTE: cloning the pathlocs is not strictly
65   *       necessary. Since we implicitely let
66   *       all threads that don't call
67   *       libio_set_private_env() share the same
68   *       (initial) 'root' and 'current' locs,
69   *       we (also implicitely) assume that the
70   *       root filesystem doesn't care about
71   *       reference counts.
72   *       I just inserted the code snippet below
73   *       to remind everybody of the fact by
74   *       making it more explicit...
75   *       Ideally, every thread would have to
76   *       call either share_private_env() or
77   *       set_private_env() - but then: that's
78   *       gonna hit performance.
79   *
80   *       Till Straumann, 10/25/2002
81   */
82  /* Clone the root pathloc */
83  rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
84  rtems_filesystem_root        = loc;
85  /* One more clone for the current node */
86  rtems_filesystem_evaluate_path("/", 1, 0, &loc, 0);
87  rtems_filesystem_current     = loc;
88
89  /* Note: the global_env's refcnt doesn't matter
90   * as the global env is never released
91   */
92
93
94  /*
95   *  Traditionally RTEMS devices are under "/dev" so install this directory.
96   *
97   *  If the mkdir() fails, we can't print anything so just fatal error.
98   *
99   *  NOTE: UNIX root is 755 and owned by root/root (0/0).  It is actually
100   *        created that way by the IMFS.
101   */
102
103  status = mkdir( "/dev", 0777);
104  if ( status != 0 )
105    rtems_fatal_error_occurred( 0xABCD0003 );
106
107  /*
108   *  You can't mount another filesystem properly until the mount point
109   *  it will be mounted onto is created.  Moreover, if it is going to
110   *  use a device, then it is REALLY unfair to attempt this
111   *  before device drivers are initialized.  So we return via a base
112   *  filesystem image and nothing auto-mounted at this point.
113   */
114}
Note: See TracBrowser for help on using the repository browser.