source: rtems/c/src/exec/libcsupport/src/base_fs.c @ 063e4950

4.104.114.84.95
Last change on this file since 063e4950 was 063e4950, checked in by Joel Sherrill <joel.sherrill@…>, on 11/02/99 at 16:27:05

Added support for configuring base filesystem. First attempt at
a full mount table at initialization. This is the wrong place
to mount filesystems 2-n since no device drivers are initialized
yet.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 *  Base file system initialization
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems.h>
16#include <rtems/libio.h>
17#include "imfs.h"
18#include "libio_.h"
19
20/*
21 *  Global information for the base file system.
22 */
23
24rtems_filesystem_location_info_t rtems_filesystem_current;
25rtems_filesystem_location_info_t rtems_filesystem_root;
26nlink_t                          rtems_filesystem_link_counts;
27
28/*
29 *  Default mode for created files.
30 */
31
32mode_t rtems_filesystem_umask;
33
34/*
35 *  rtems_filesystem_initialize
36 *
37 *  Initialize the foundation of the file system with one instantiation
38 *  of the IMFS with a single "/dev" directory in it.
39 */
40
41void rtems_filesystem_initialize( void )
42{
43#if !defined(RTEMS_UNIX)
44#if 0
45  int                                   i;
46#endif
47  int                                   status;
48  rtems_filesystem_mount_table_entry_t *entry;
49  rtems_filesystem_mount_table_t       *mt;
50 
51  /*
52   *  Set the default umask to "022".
53   */
54
55  rtems_filesystem_umask = S_IWOTH | S_IROTH;
56
57  init_fs_mount_table();
58
59  /*
60   *  mount the first filesystem.
61   */
62
63  if ( rtems_filesystem_mount_table_size == 0 )
64    rtems_fatal_error_occurred( 0xABCD0001 );
65
66  mt = &rtems_filesystem_mount_table[0];
67
68  status = mount(
69     &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
70
71  if ( status == -1 )
72    rtems_fatal_error_occurred( 0xABCD0002 );
73
74  rtems_filesystem_link_counts = 0;
75  rtems_filesystem_root        = entry->mt_fs_root;
76  rtems_filesystem_current     = rtems_filesystem_root;
77
78  /*
79   *  Traditionally RTEMS devices are under "/dev" so install this directory.
80   *
81   *  If the mkdir() fails, we can't print anything so just fatal error.
82   *
83   *  NOTE: UNIX root is 755 and owned by root/root (0/0).
84   */
85
86  status = mkdir( "/dev", S_IRWXU | S_IRWXG | S_IRWXO );
87  if ( status != 0 )
88    rtems_fatal_error_occurred( 0xABCD0003 );
89
90  /*
91   *  This code if if'ed 0 out because you can't mount another
92   *  filesystem properly until the mount point it will be
93   *  mounted onto is created.  Moreover, if it is going to
94   *  use a device, then it is REALLY unfair to attempt this
95   *  before device drivers are initialized.
96   */
97
98#if 0
99  /*
100   *  Now if there are other filesystems to mount, go for it.
101   */
102
103  for ( i=1 ; i < rtems_filesystem_mount_table_size ; i++ ) {
104    mt = &rtems_filesystem_mount_table[0];
105
106    status = mount(
107       &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
108
109    if ( status == -1 )
110      rtems_fatal_error_occurred( 0xABCD0003 );
111  }
112#endif
113#endif
114}
Note: See TracBrowser for help on using the repository browser.