1 | /* |
---|
2 | * IMFS 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 <sys/types.h> /* for mkdir */ |
---|
19 | #include <fcntl.h> |
---|
20 | #include <unistd.h> |
---|
21 | #include <stdlib.h> |
---|
22 | |
---|
23 | #include <assert.h> |
---|
24 | |
---|
25 | #include "imfs.h" |
---|
26 | #include <rtems/libio_.h> |
---|
27 | |
---|
28 | #if defined(IMFS_DEBUG) |
---|
29 | #include <stdio.h> |
---|
30 | #endif |
---|
31 | |
---|
32 | /* |
---|
33 | * IMFS_initialize |
---|
34 | */ |
---|
35 | |
---|
36 | int IMFS_initialize_support( |
---|
37 | rtems_filesystem_mount_table_entry_t *temp_mt_entry, |
---|
38 | rtems_filesystem_operations_table *op_table, |
---|
39 | rtems_filesystem_file_handlers_r *linearfile_handlers, |
---|
40 | rtems_filesystem_file_handlers_r *memfile_handlers, |
---|
41 | rtems_filesystem_file_handlers_r *directory_handlers |
---|
42 | ) |
---|
43 | { |
---|
44 | IMFS_fs_info_t *fs_info; |
---|
45 | IMFS_jnode_t *jnode; |
---|
46 | |
---|
47 | /* |
---|
48 | * Create the root node |
---|
49 | * |
---|
50 | * NOTE: UNIX root is 755 and owned by root/root (0/0). |
---|
51 | */ |
---|
52 | |
---|
53 | temp_mt_entry->mt_fs_root.node_access = IMFS_create_node( |
---|
54 | NULL, |
---|
55 | IMFS_DIRECTORY, |
---|
56 | "", |
---|
57 | ( S_IFDIR | 0755 ), |
---|
58 | NULL |
---|
59 | ); |
---|
60 | |
---|
61 | temp_mt_entry->mt_fs_root.handlers = directory_handlers; |
---|
62 | temp_mt_entry->mt_fs_root.ops = op_table; |
---|
63 | temp_mt_entry->pathconf_limits_and_options = IMFS_LIMITS_AND_OPTIONS; |
---|
64 | |
---|
65 | /* |
---|
66 | * Create custom file system data. |
---|
67 | */ |
---|
68 | fs_info = calloc( 1, sizeof( IMFS_fs_info_t ) ); |
---|
69 | if ( !fs_info ){ |
---|
70 | free(temp_mt_entry->mt_fs_root.node_access); |
---|
71 | return 1; |
---|
72 | } |
---|
73 | temp_mt_entry->fs_info = fs_info; |
---|
74 | |
---|
75 | /* |
---|
76 | * Set st_ino for the root to 1. |
---|
77 | */ |
---|
78 | |
---|
79 | fs_info->ino_count = 1; |
---|
80 | fs_info->linearfile_handlers = linearfile_handlers; |
---|
81 | fs_info->memfile_handlers = memfile_handlers; |
---|
82 | fs_info->directory_handlers = directory_handlers; |
---|
83 | |
---|
84 | jnode = temp_mt_entry->mt_fs_root.node_access; |
---|
85 | jnode->st_ino = fs_info->ino_count; |
---|
86 | |
---|
87 | return 0; |
---|
88 | } |
---|