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 | #include <rtems.h> |
---|
15 | #include <rtems/libio.h> |
---|
16 | #include "imfs.h" |
---|
17 | #include "libio_.h" |
---|
18 | |
---|
19 | /* |
---|
20 | * Global information for the base file system. |
---|
21 | */ |
---|
22 | |
---|
23 | rtems_filesystem_location_info_t rtems_filesystem_current; |
---|
24 | rtems_filesystem_location_info_t rtems_filesystem_root; |
---|
25 | nlink_t rtems_filesystem_link_counts; |
---|
26 | |
---|
27 | /* |
---|
28 | * Default mode for created files. |
---|
29 | */ |
---|
30 | |
---|
31 | mode_t rtems_filesystem_umask; |
---|
32 | |
---|
33 | /* |
---|
34 | * rtems_filesystem_initialize |
---|
35 | * |
---|
36 | * Initialize the foundation of the file system with one instantiation |
---|
37 | * of the IMFS with a single "/dev" directory in it. |
---|
38 | */ |
---|
39 | |
---|
40 | void rtems_filesystem_initialize( void ) |
---|
41 | { |
---|
42 | #if !defined(RTEMS_UNIX) |
---|
43 | #if 0 |
---|
44 | int i; |
---|
45 | #endif |
---|
46 | int status; |
---|
47 | rtems_filesystem_mount_table_entry_t *entry; |
---|
48 | rtems_filesystem_mount_table_t *mt; |
---|
49 | |
---|
50 | /* |
---|
51 | * Set the default umask to "022". |
---|
52 | */ |
---|
53 | |
---|
54 | rtems_filesystem_umask = S_IWOTH | S_IROTH; |
---|
55 | |
---|
56 | init_fs_mount_table(); |
---|
57 | |
---|
58 | /* |
---|
59 | * mount the first filesystem. |
---|
60 | */ |
---|
61 | |
---|
62 | if ( rtems_filesystem_mount_table_size == 0 ) |
---|
63 | rtems_fatal_error_occurred( 0xABCD0001 ); |
---|
64 | |
---|
65 | mt = &rtems_filesystem_mount_table[0]; |
---|
66 | |
---|
67 | status = mount( |
---|
68 | &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point ); |
---|
69 | |
---|
70 | if ( status == -1 ) |
---|
71 | rtems_fatal_error_occurred( 0xABCD0002 ); |
---|
72 | |
---|
73 | rtems_filesystem_link_counts = 0; |
---|
74 | rtems_filesystem_root = entry->mt_fs_root; |
---|
75 | rtems_filesystem_current = rtems_filesystem_root; |
---|
76 | |
---|
77 | /* |
---|
78 | * Traditionally RTEMS devices are under "/dev" so install this directory. |
---|
79 | * |
---|
80 | * If the mkdir() fails, we can't print anything so just fatal error. |
---|
81 | * |
---|
82 | * NOTE: UNIX root is 755 and owned by root/root (0/0). |
---|
83 | */ |
---|
84 | |
---|
85 | status = mkdir( "/dev", S_IRWXU | S_IRWXG | S_IRWXO ); |
---|
86 | if ( status != 0 ) |
---|
87 | rtems_fatal_error_occurred( 0xABCD0003 ); |
---|
88 | |
---|
89 | /* |
---|
90 | * This code if if'ed 0 out because you can't mount another |
---|
91 | * filesystem properly until the mount point it will be |
---|
92 | * mounted onto is created. Moreover, if it is going to |
---|
93 | * use a device, then it is REALLY unfair to attempt this |
---|
94 | * before device drivers are initialized. |
---|
95 | */ |
---|
96 | |
---|
97 | #if 0 |
---|
98 | /* |
---|
99 | * Now if there are other filesystems to mount, go for it. |
---|
100 | */ |
---|
101 | |
---|
102 | for ( i=1 ; i < rtems_filesystem_mount_table_size ; i++ ) { |
---|
103 | mt = &rtems_filesystem_mount_table[0]; |
---|
104 | |
---|
105 | status = mount( |
---|
106 | &entry, mt->fs_ops, mt->fsoptions, mt->device, mt->mount_point ); |
---|
107 | |
---|
108 | if ( status == -1 ) |
---|
109 | rtems_fatal_error_occurred( 0xABCD0003 ); |
---|
110 | } |
---|
111 | #endif |
---|
112 | #endif |
---|
113 | } |
---|