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 | |
---|
26 | rtems_user_env_t rtems_global_user_env; |
---|
27 | rtems_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 | |
---|
43 | void 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 = S_IWOTH | S_IROTH; |
---|
58 | |
---|
59 | init_fs_mount_table(); |
---|
60 | |
---|
61 | /* |
---|
62 | * mount the first filesystem. |
---|
63 | */ |
---|
64 | |
---|
65 | if ( rtems_filesystem_mount_table_size == 0 ) |
---|
66 | rtems_fatal_error_occurred( 0xABCD0001 ); |
---|
67 | |
---|
68 | mt = &rtems_filesystem_mount_table[0]; |
---|
69 | |
---|
70 | status = mount( |
---|
71 | &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point ); |
---|
72 | |
---|
73 | if ( status == -1 ) |
---|
74 | rtems_fatal_error_occurred( 0xABCD0002 ); |
---|
75 | |
---|
76 | rtems_filesystem_link_counts = 0; |
---|
77 | rtems_filesystem_root = entry->mt_fs_root; |
---|
78 | rtems_filesystem_current = rtems_filesystem_root; |
---|
79 | |
---|
80 | /* |
---|
81 | * Traditionally RTEMS devices are under "/dev" so install this directory. |
---|
82 | * |
---|
83 | * If the mkdir() fails, we can't print anything so just fatal error. |
---|
84 | * |
---|
85 | * NOTE: UNIX root is 755 and owned by root/root (0/0). |
---|
86 | */ |
---|
87 | |
---|
88 | status = mkdir( "/dev", S_IRWXU | S_IRWXG | S_IRWXO ); |
---|
89 | if ( status != 0 ) |
---|
90 | rtems_fatal_error_occurred( 0xABCD0003 ); |
---|
91 | |
---|
92 | /* |
---|
93 | * This code if if'ed 0 out because you can't mount another |
---|
94 | * filesystem properly until the mount point it will be |
---|
95 | * mounted onto is created. Moreover, if it is going to |
---|
96 | * use a device, then it is REALLY unfair to attempt this |
---|
97 | * before device drivers are initialized. |
---|
98 | */ |
---|
99 | |
---|
100 | #if 0 |
---|
101 | /* |
---|
102 | * Now if there are other filesystems to mount, go for it. |
---|
103 | */ |
---|
104 | |
---|
105 | for ( i=1 ; i < rtems_filesystem_mount_table_size ; i++ ) { |
---|
106 | mt = &rtems_filesystem_mount_table[0]; |
---|
107 | |
---|
108 | status = mount( |
---|
109 | &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point ); |
---|
110 | |
---|
111 | if ( status == -1 ) |
---|
112 | rtems_fatal_error_occurred( 0xABCD0003 ); |
---|
113 | } |
---|
114 | #endif |
---|
115 | #endif |
---|
116 | } |
---|