[07a3253d] | 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 | |
---|
| 24 | rtems_filesystem_location_info_t rtems_filesystem_current; |
---|
| 25 | rtems_filesystem_location_info_t rtems_filesystem_root; |
---|
| 26 | nlink_t rtems_filesystem_link_counts; |
---|
| 27 | |
---|
| 28 | /* |
---|
| 29 | * Default mode for created files. |
---|
| 30 | */ |
---|
| 31 | |
---|
| 32 | mode_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 | |
---|
| 41 | void rtems_filesystem_initialize( void ) |
---|
| 42 | { |
---|
[7a3878b] | 43 | #if !defined(RTEMS_UNIX) |
---|
[07a3253d] | 44 | int status; |
---|
| 45 | rtems_filesystem_mount_table_entry_t *first_entry; |
---|
| 46 | |
---|
| 47 | /* |
---|
| 48 | * Set the default umask to "022". |
---|
| 49 | */ |
---|
| 50 | |
---|
| 51 | rtems_filesystem_umask = S_IWOTH | S_IROTH; |
---|
| 52 | |
---|
| 53 | init_fs_mount_table(); |
---|
| 54 | |
---|
[657e1bf6] | 55 | /* |
---|
| 56 | * mount the first filesystem. |
---|
| 57 | * |
---|
| 58 | * NOTE: XXX This really needs to be read from a table of filesystems |
---|
| 59 | * to mount initially and the miniIMFS needs to be shaken out. |
---|
| 60 | */ |
---|
| 61 | |
---|
[07a3253d] | 62 | status = mount( |
---|
| 63 | &first_entry, |
---|
| 64 | &IMFS_ops, |
---|
[937ab62c] | 65 | RTEMS_FILESYSTEM_READ_WRITE, |
---|
[07a3253d] | 66 | NULL, |
---|
| 67 | NULL ); |
---|
| 68 | if( status == -1 ){ |
---|
| 69 | rtems_fatal_error_occurred( 0xABCD0002 ); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | rtems_filesystem_link_counts = 0; |
---|
| 73 | |
---|
| 74 | rtems_filesystem_root = first_entry->mt_fs_root; |
---|
| 75 | |
---|
| 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 ); |
---|
[7a3878b] | 89 | #endif |
---|
[07a3253d] | 90 | } |
---|