Rev 4537 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4537 | Rev 4668 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | #include <errno.h> |
41 | #include <errno.h> |
42 | #include <stdio.h> |
42 | #include <stdio.h> |
43 | #include <bool.h> |
43 | #include <bool.h> |
44 | #include <string.h> |
44 | #include <string.h> |
45 | #include <as.h> |
45 | #include <as.h> |
46 | #include <adt/list.h> |
- | |
47 | #include <atomic.h> |
46 | #include <atomic.h> |
48 | #include "vfs.h" |
47 | #include "vfs.h" |
49 | 48 | ||
50 | #define NAME "vfs" |
49 | #define NAME "vfs" |
51 | 50 | ||
Line 78... | Line 77... | ||
78 | 77 | ||
79 | switch (IPC_GET_METHOD(call)) { |
78 | switch (IPC_GET_METHOD(call)) { |
80 | case IPC_M_PHONE_HUNGUP: |
79 | case IPC_M_PHONE_HUNGUP: |
81 | keep_on_going = false; |
80 | keep_on_going = false; |
82 | break; |
81 | break; |
83 | case VFS_REGISTER: |
82 | case VFS_IN_REGISTER: |
84 | vfs_register(callid, &call); |
83 | vfs_register(callid, &call); |
85 | /* |
- | |
86 | * Keep the connection open so that a file system can |
84 | keep_on_going = false; |
87 | * later ask us to connect it to another file system. |
- | |
88 | * This is necessary to support non-root mounts. |
- | |
89 | */ |
- | |
90 | break; |
85 | break; |
91 | case VFS_MOUNT: |
86 | case VFS_IN_MOUNT: |
92 | vfs_mount(callid, &call); |
87 | vfs_mount(callid, &call); |
93 | break; |
88 | break; |
94 | case VFS_OPEN: |
89 | case VFS_IN_OPEN: |
95 | vfs_open(callid, &call); |
90 | vfs_open(callid, &call); |
96 | break; |
91 | break; |
97 | case VFS_OPEN_NODE: |
92 | case VFS_IN_OPEN_NODE: |
98 | vfs_open_node(callid, &call); |
93 | vfs_open_node(callid, &call); |
99 | break; |
94 | break; |
100 | case VFS_CLOSE: |
95 | case VFS_IN_CLOSE: |
101 | vfs_close(callid, &call); |
96 | vfs_close(callid, &call); |
102 | break; |
97 | break; |
103 | case VFS_READ: |
98 | case VFS_IN_READ: |
104 | vfs_read(callid, &call); |
99 | vfs_read(callid, &call); |
105 | break; |
100 | break; |
106 | case VFS_WRITE: |
101 | case VFS_IN_WRITE: |
107 | vfs_write(callid, &call); |
102 | vfs_write(callid, &call); |
108 | break; |
103 | break; |
109 | case VFS_SEEK: |
104 | case VFS_IN_SEEK: |
110 | vfs_seek(callid, &call); |
105 | vfs_seek(callid, &call); |
111 | break; |
106 | break; |
112 | case VFS_TRUNCATE: |
107 | case VFS_IN_TRUNCATE: |
113 | vfs_truncate(callid, &call); |
108 | vfs_truncate(callid, &call); |
114 | break; |
109 | break; |
- | 110 | case VFS_IN_FSTAT: |
|
- | 111 | vfs_fstat(callid, &call); |
|
- | 112 | break; |
|
- | 113 | case VFS_IN_STAT: |
|
- | 114 | vfs_stat(callid, &call); |
|
- | 115 | break; |
|
115 | case VFS_MKDIR: |
116 | case VFS_IN_MKDIR: |
116 | vfs_mkdir(callid, &call); |
117 | vfs_mkdir(callid, &call); |
117 | break; |
118 | break; |
118 | case VFS_UNLINK: |
119 | case VFS_IN_UNLINK: |
119 | vfs_unlink(callid, &call); |
120 | vfs_unlink(callid, &call); |
120 | break; |
121 | break; |
121 | case VFS_RENAME: |
122 | case VFS_IN_RENAME: |
122 | vfs_rename(callid, &call); |
123 | vfs_rename(callid, &call); |
123 | break; |
124 | break; |
124 | case VFS_DEVICE: |
- | |
125 | vfs_device(callid, &call); |
- | |
126 | break; |
- | |
127 | case VFS_SYNC: |
125 | case VFS_IN_SYNC: |
128 | vfs_sync(callid, &call); |
126 | vfs_sync(callid, &call); |
129 | break; |
127 | break; |
130 | case VFS_NODE: |
- | |
131 | vfs_node(callid, &call); |
- | |
132 | break; |
- | |
133 | default: |
128 | default: |
134 | ipc_answer_0(callid, ENOTSUP); |
129 | ipc_answer_0(callid, ENOTSUP); |
135 | break; |
130 | break; |
136 | } |
131 | } |
137 | } |
132 | } |
Line 142... | Line 137... | ||
142 | int main(int argc, char **argv) |
137 | int main(int argc, char **argv) |
143 | { |
138 | { |
144 | printf(NAME ": HelenOS VFS server\n"); |
139 | printf(NAME ": HelenOS VFS server\n"); |
145 | 140 | ||
146 | /* |
141 | /* |
147 | * Initialize the list of registered file systems. |
- | |
148 | */ |
- | |
149 | list_initialize(&fs_head); |
- | |
150 | - | ||
151 | /* |
- | |
152 | * Initialize VFS node hash table. |
142 | * Initialize VFS node hash table. |
153 | */ |
143 | */ |
154 | if (!vfs_nodes_init()) { |
144 | if (!vfs_nodes_init()) { |
155 | printf(NAME ": Failed to initialize VFS node hash table\n"); |
145 | printf(NAME ": Failed to initialize VFS node hash table\n"); |
156 | return ENOMEM; |
146 | return ENOMEM; |
157 | } |
147 | } |
158 | 148 | ||
159 | /* |
149 | /* |
160 | * Allocate and initialize the Path Lookup Buffer. |
150 | * Allocate and initialize the Path Lookup Buffer. |
161 | */ |
151 | */ |
162 | list_initialize(&plb_head); |
- | |
163 | plb = as_get_mappable_page(PLB_SIZE); |
152 | plb = as_get_mappable_page(PLB_SIZE); |
164 | if (!plb) { |
153 | if (!plb) { |
165 | printf(NAME ": Cannot allocate a mappable piece of address space\n"); |
154 | printf(NAME ": Cannot allocate a mappable piece of address space\n"); |
166 | return ENOMEM; |
155 | return ENOMEM; |
167 | } |
156 | } |
Line 172... | Line 161... | ||
172 | return ENOMEM; |
161 | return ENOMEM; |
173 | } |
162 | } |
174 | memset(plb, 0, PLB_SIZE); |
163 | memset(plb, 0, PLB_SIZE); |
175 | 164 | ||
176 | /* |
165 | /* |
177 | * Set a connectio handling function/fibril. |
166 | * Set a connection handling function/fibril. |
178 | */ |
167 | */ |
179 | async_set_pending(vfs_process_pending_mount); |
- | |
180 | async_set_client_connection(vfs_connection); |
168 | async_set_client_connection(vfs_connection); |
181 | 169 | ||
182 | /* |
170 | /* |
183 | * Register at the naming service. |
171 | * Register at the naming service. |
184 | */ |
172 | */ |
185 | ipcarg_t phonead; |
173 | ipcarg_t phonead; |
186 | ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead); |
174 | ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, &phonead); |