source: rtems/c/src/lib/libc/base_fs.c @ e565720a

4.104.114.84.95
Last change on this file since e565720a was e565720a, checked in by Joel Sherrill <joel.sherrill@…>, on 05/24/01 at 21:43:08

2000-05-24 Fernando Ruiz Casas <fernando.ruiz@…>

  • libc/ttyname.c (ttyname_r): Removed duplicate call to closedir().
  • libc/getpwent.c: Create a more robust /etc/passwd and /etc/group.
  • libc/base_fs.c: Change permissions of files and directories. Now uses octal constants.
  • Property mode set to 100644
File size: 2.8 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.OARcorp.com/rtems/license.html.
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 
53  /*
54   *  Set the default umask to "022".
55   */
56
57  rtems_filesystem_umask = 022;
58
59
60  init_fs_mount_table();
61
62  /*
63   *  mount the first filesystem.
64   */
65
66  if ( rtems_filesystem_mount_table_size == 0 )
67    rtems_fatal_error_occurred( 0xABCD0001 );
68
69  mt = &rtems_filesystem_mount_table[0];
70
71  status = mount(
72     &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
73
74  if ( status == -1 )
75    rtems_fatal_error_occurred( 0xABCD0002 );
76
77  rtems_filesystem_link_counts = 0;
78  rtems_filesystem_root        = entry->mt_fs_root;
79  rtems_filesystem_current     = rtems_filesystem_root;
80
81
82  /*
83   *  Traditionally RTEMS devices are under "/dev" so install this directory.
84   *
85   *  If the mkdir() fails, we can't print anything so just fatal error.
86   *
87   *  NOTE: UNIX root is 755 and owned by root/root (0/0).
88   */
89  status=chmod("/", 0755);
90  if ( status != 0 )
91    rtems_fatal_error_occurred( 0xABCD0003 );
92
93  status = mkdir( "/dev", 0777);
94  if ( status != 0 )
95    rtems_fatal_error_occurred( 0xABCD0003 );
96
97  /*
98   *  This code if if'ed 0 out because you can't mount another
99   *  filesystem properly until the mount point it will be
100   *  mounted onto is created.  Moreover, if it is going to
101   *  use a device, then it is REALLY unfair to attempt this
102   *  before device drivers are initialized.
103   */
104
105#if 0
106  /*
107   *  Now if there are other filesystems to mount, go for it.
108   */
109
110  for ( i=1 ; i < rtems_filesystem_mount_table_size ; i++ ) {
111    mt = &rtems_filesystem_mount_table[0];
112
113    status = mount(
114       &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point );
115
116    if ( status == -1 )
117      rtems_fatal_error_occurred( 0xABCD0003 );
118  }
119#endif
120#endif
121}
Note: See TracBrowser for help on using the repository browser.