Rev 2576 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2576 | Rev 2588 | ||
---|---|---|---|
Line 157... | Line 157... | ||
157 | if (!ipc_data_receive(&callid, &call, NULL, &size)) { |
157 | if (!ipc_data_receive(&callid, &call, NULL, &size)) { |
158 | /* |
158 | /* |
159 | * The client doesn't obey the same protocol as we do. |
159 | * The client doesn't obey the same protocol as we do. |
160 | */ |
160 | */ |
161 | dprintf("Receiving of VFS info failed.\n"); |
161 | dprintf("Receiving of VFS info failed.\n"); |
162 | ipc_answer_fast(callid, EINVAL, 0, 0); |
162 | ipc_answer_fast_0(callid, EINVAL); |
163 | ipc_answer_fast(rid, EINVAL, 0, 0); |
163 | ipc_answer_fast_0(rid, EINVAL); |
164 | return; |
164 | return; |
165 | } |
165 | } |
166 | 166 | ||
167 | dprintf("VFS info received, size = %d\n", size); |
167 | dprintf("VFS info received, size = %d\n", size); |
168 | 168 | ||
Line 174... | Line 174... | ||
174 | /* |
174 | /* |
175 | * The client is sending us something, which cannot be |
175 | * The client is sending us something, which cannot be |
176 | * the info structure. |
176 | * the info structure. |
177 | */ |
177 | */ |
178 | dprintf("Received VFS info has bad size.\n"); |
178 | dprintf("Received VFS info has bad size.\n"); |
179 | ipc_answer_fast(callid, EINVAL, 0, 0); |
179 | ipc_answer_fast_0(callid, EINVAL); |
180 | ipc_answer_fast(rid, EINVAL, 0, 0); |
180 | ipc_answer_fast_0(rid, EINVAL); |
181 | return; |
181 | return; |
182 | } |
182 | } |
183 | 183 | ||
184 | /* |
184 | /* |
185 | * Allocate and initialize a buffer for the fs_info structure. |
185 | * Allocate and initialize a buffer for the fs_info structure. |
186 | */ |
186 | */ |
187 | fs_info_t *fs_info; |
187 | fs_info_t *fs_info; |
188 | fs_info = (fs_info_t *) malloc(sizeof(fs_info_t)); |
188 | fs_info = (fs_info_t *) malloc(sizeof(fs_info_t)); |
189 | if (!fs_info) { |
189 | if (!fs_info) { |
190 | dprintf("Could not allocate memory for FS info.\n"); |
190 | dprintf("Could not allocate memory for FS info.\n"); |
191 | ipc_answer_fast(callid, ENOMEM, 0, 0); |
191 | ipc_answer_fast_0(callid, ENOMEM); |
192 | ipc_answer_fast(rid, ENOMEM, 0, 0); |
192 | ipc_answer_fast_0(rid, ENOMEM); |
193 | return; |
193 | return; |
194 | } |
194 | } |
195 | link_initialize(&fs_info->fs_link); |
195 | link_initialize(&fs_info->fs_link); |
196 | 196 | ||
197 | rc = ipc_data_deliver(callid, &call, &fs_info->vfs_info, size); |
197 | rc = ipc_data_deliver(callid, &call, &fs_info->vfs_info, size); |
198 | if (rc != EOK) { |
198 | if (rc != EOK) { |
199 | dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", |
199 | dprintf("Failed to deliver the VFS info into our AS, rc=%d.\n", |
200 | rc); |
200 | rc); |
201 | free(fs_info); |
201 | free(fs_info); |
202 | ipc_answer_fast(callid, rc, 0, 0); |
202 | ipc_answer_fast_0(callid, rc); |
203 | ipc_answer_fast(rid, rc, 0, 0); |
203 | ipc_answer_fast_0(rid, rc); |
204 | return; |
204 | return; |
205 | } |
205 | } |
206 | 206 | ||
207 | dprintf("VFS info delivered.\n"); |
207 | dprintf("VFS info delivered.\n"); |
208 | 208 | ||
209 | if (!vfs_info_sane(&fs_info->vfs_info)) { |
209 | if (!vfs_info_sane(&fs_info->vfs_info)) { |
210 | free(fs_info); |
210 | free(fs_info); |
211 | ipc_answer_fast(callid, EINVAL, 0, 0); |
211 | ipc_answer_fast_0(callid, EINVAL); |
212 | ipc_answer_fast(rid, EINVAL, 0, 0); |
212 | ipc_answer_fast_0(rid, EINVAL); |
213 | return; |
213 | return; |
214 | } |
214 | } |
215 | 215 | ||
216 | futex_down(&fs_head_futex); |
216 | futex_down(&fs_head_futex); |
217 | 217 | ||
Line 223... | Line 223... | ||
223 | * We already register a fs like this. |
223 | * We already register a fs like this. |
224 | */ |
224 | */ |
225 | dprintf("FS is already registered.\n"); |
225 | dprintf("FS is already registered.\n"); |
226 | futex_up(&fs_head_futex); |
226 | futex_up(&fs_head_futex); |
227 | free(fs_info); |
227 | free(fs_info); |
228 | ipc_answer_fast(callid, EEXISTS, 0, 0); |
228 | ipc_answer_fast_0(callid, EEXISTS); |
229 | ipc_answer_fast(rid, EEXISTS, 0, 0); |
229 | ipc_answer_fast_0(rid, EEXISTS); |
230 | return; |
230 | return; |
231 | } |
231 | } |
232 | 232 | ||
233 | /* |
233 | /* |
234 | * Add fs_info to the list of registered FS's. |
234 | * Add fs_info to the list of registered FS's. |
Line 245... | Line 245... | ||
245 | if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) { |
245 | if (IPC_GET_METHOD(call) != IPC_M_CONNECT_TO_ME) { |
246 | dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); |
246 | dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); |
247 | list_remove(&fs_info->fs_link); |
247 | list_remove(&fs_info->fs_link); |
248 | futex_up(&fs_head_futex); |
248 | futex_up(&fs_head_futex); |
249 | free(fs_info); |
249 | free(fs_info); |
250 | ipc_answer_fast(callid, EINVAL, 0, 0); |
250 | ipc_answer_fast_0(callid, EINVAL); |
251 | ipc_answer_fast(rid, EINVAL, 0, 0); |
251 | ipc_answer_fast_0(rid, EINVAL); |
252 | return; |
252 | return; |
253 | } |
253 | } |
254 | fs_info->phone = IPC_GET_ARG3(call); |
254 | fs_info->phone = IPC_GET_ARG3(call); |
255 | ipc_answer_fast(callid, EOK, 0, 0); |
255 | ipc_answer_fast_0(callid, EOK); |
256 | 256 | ||
257 | dprintf("Callback connection to FS created.\n"); |
257 | dprintf("Callback connection to FS created.\n"); |
258 | 258 | ||
259 | /* |
259 | /* |
260 | * The client will want us to send him the address space area with PLB. |
260 | * The client will want us to send him the address space area with PLB. |
Line 264... | Line 264... | ||
264 | dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); |
264 | dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call)); |
265 | list_remove(&fs_info->fs_link); |
265 | list_remove(&fs_info->fs_link); |
266 | futex_up(&fs_head_futex); |
266 | futex_up(&fs_head_futex); |
267 | ipc_hangup(fs_info->phone); |
267 | ipc_hangup(fs_info->phone); |
268 | free(fs_info); |
268 | free(fs_info); |
269 | ipc_answer_fast(callid, EINVAL, 0, 0); |
269 | ipc_answer_fast_0(callid, EINVAL); |
270 | ipc_answer_fast(rid, EINVAL, 0, 0); |
270 | ipc_answer_fast_0(rid, EINVAL); |
271 | return; |
271 | return; |
272 | } |
272 | } |
273 | 273 | ||
274 | /* |
274 | /* |
275 | * We can only send the client address space area PLB_SIZE bytes long. |
275 | * We can only send the client address space area PLB_SIZE bytes long. |
Line 279... | Line 279... | ||
279 | dprintf("Client suggests wrong size of PFB, size = %d\n", size); |
279 | dprintf("Client suggests wrong size of PFB, size = %d\n", size); |
280 | list_remove(&fs_info->fs_link); |
280 | list_remove(&fs_info->fs_link); |
281 | futex_up(&fs_head_futex); |
281 | futex_up(&fs_head_futex); |
282 | ipc_hangup(fs_info->phone); |
282 | ipc_hangup(fs_info->phone); |
283 | free(fs_info); |
283 | free(fs_info); |
284 | ipc_answer_fast(callid, EINVAL, 0, 0); |
284 | ipc_answer_fast_0(callid, EINVAL); |
285 | ipc_answer_fast(rid, EINVAL, 0, 0); |
285 | ipc_answer_fast_0(rid, EINVAL); |
286 | return; |
286 | return; |
287 | } |
287 | } |
288 | 288 | ||
289 | /* |
289 | /* |
290 | * Commit to read-only sharing the PLB with the client. |
290 | * Commit to read-only sharing the PLB with the client. |
Line 298... | Line 298... | ||
298 | * That was it. The FS has been registered. |
298 | * That was it. The FS has been registered. |
299 | * In reply to the VFS_REGISTER request, we assign the client file |
299 | * In reply to the VFS_REGISTER request, we assign the client file |
300 | * system a global file system handle. |
300 | * system a global file system handle. |
301 | */ |
301 | */ |
302 | fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next); |
302 | fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next); |
303 | ipc_answer_fast(rid, EOK, (ipcarg_t) fs_info->fs_handle, 0); |
303 | ipc_answer_fast_1(rid, EOK, (ipcarg_t) fs_info->fs_handle); |
304 | 304 | ||
305 | futex_up(&fs_head_futex); |
305 | futex_up(&fs_head_futex); |
306 | 306 | ||
307 | dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n", |
307 | dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n", |
308 | FS_NAME_MAXLEN, fs_info->vfs_info.name, fs_info->fs_handle); |
308 | FS_NAME_MAXLEN, fs_info->vfs_info.name, fs_info->fs_handle); |