1 | /* |
---|
2 | * Base file system initialization |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2008. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * Modifications to support reference counting in the file system are |
---|
8 | * Copyright (c) 2012 embedded brains GmbH. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #if HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #include <rtems.h> |
---|
20 | #include <rtems/libio.h> |
---|
21 | #include <rtems/libio_.h> |
---|
22 | |
---|
23 | /* |
---|
24 | * Default mode for created files. |
---|
25 | */ |
---|
26 | |
---|
27 | |
---|
28 | /* |
---|
29 | * rtems_filesystem_initialize |
---|
30 | * |
---|
31 | * Initialize the foundation of the file system. This is specified |
---|
32 | * by the structure rtems_filesystem_mount_table. The usual |
---|
33 | * configuration is a single instantiation of the IMFS or miniIMFS with |
---|
34 | * a single "/dev" directory in it. |
---|
35 | */ |
---|
36 | |
---|
37 | void rtems_filesystem_initialize( void ) |
---|
38 | { |
---|
39 | int rv = 0; |
---|
40 | const rtems_filesystem_mount_configuration *root_config = |
---|
41 | &rtems_filesystem_root_configuration; |
---|
42 | |
---|
43 | rv = mount( |
---|
44 | root_config->source, |
---|
45 | root_config->target, |
---|
46 | root_config->filesystemtype, |
---|
47 | root_config->options, |
---|
48 | root_config->data |
---|
49 | ); |
---|
50 | if ( rv != 0 ) |
---|
51 | rtems_fatal_error_occurred( 0xABCD0002 ); |
---|
52 | |
---|
53 | /* |
---|
54 | * Traditionally RTEMS devices are under "/dev" so install this directory. |
---|
55 | * |
---|
56 | * If the mkdir() fails, we can't print anything so just fatal error. |
---|
57 | * |
---|
58 | * NOTE: UNIX root is 755 and owned by root/root (0/0). It is actually |
---|
59 | * created that way by the IMFS. |
---|
60 | */ |
---|
61 | |
---|
62 | rv = mkdir( "/dev", 0777); |
---|
63 | if ( rv != 0 ) |
---|
64 | rtems_fatal_error_occurred( 0xABCD0003 ); |
---|
65 | |
---|
66 | /* |
---|
67 | * You can't mount another filesystem properly until the mount point |
---|
68 | * it will be mounted onto is created. Moreover, if it is going to |
---|
69 | * use a device, then it is REALLY unfair to attempt this |
---|
70 | * before device drivers are initialized. So we return via a base |
---|
71 | * filesystem image and nothing auto-mounted at this point. |
---|
72 | */ |
---|
73 | } |
---|