Rev 2546 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2546 | Rev 2548 | ||
---|---|---|---|
Line 216... | Line 216... | ||
216 | futex_down(&fs_head_futex); |
216 | futex_down(&fs_head_futex); |
217 | 217 | ||
218 | /* |
218 | /* |
219 | * Check for duplicit registrations. |
219 | * Check for duplicit registrations. |
220 | */ |
220 | */ |
221 | link_t *cur; |
- | |
222 | for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { |
- | |
223 | fs_info_t *fi = list_get_instance(cur, fs_info_t, |
- | |
224 | fs_link); |
- | |
225 | /* TODO: replace strcmp with strncmp once we have it */ |
- | |
226 | if (strcmp(fs_info->vfs_info.name, fi->vfs_info.name) == 0) { |
221 | if (fs_name_to_handle(fs_info->vfs_info.name, false)) { |
227 | /* |
222 | /* |
228 | * We already register a fs like this. |
223 | * We already register a fs like this. |
229 | */ |
224 | */ |
230 | dprintf("FS is already registered.\n"); |
225 | dprintf("FS is already registered.\n"); |
231 | futex_up(&fs_head_futex); |
226 | futex_up(&fs_head_futex); |
232 | free(fs_info); |
227 | free(fs_info); |
233 | ipc_answer_fast(callid, EEXISTS, 0, 0); |
228 | ipc_answer_fast(callid, EEXISTS, 0, 0); |
234 | ipc_answer_fast(rid, EEXISTS, 0, 0); |
229 | ipc_answer_fast(rid, EEXISTS, 0, 0); |
235 | return; |
230 | return; |
236 | } |
- | |
237 | } |
231 | } |
238 | 232 | ||
239 | /* |
233 | /* |
240 | * Add fs_info to the list of registered FS's. |
234 | * Add fs_info to the list of registered FS's. |
241 | */ |
235 | */ |
Line 304... | Line 298... | ||
304 | ipc_answer_fast(callid, EOK, (ipcarg_t) plb, |
298 | ipc_answer_fast(callid, EOK, (ipcarg_t) plb, |
305 | (ipcarg_t) (AS_AREA_READ | AS_AREA_CACHEABLE)); |
299 | (ipcarg_t) (AS_AREA_READ | AS_AREA_CACHEABLE)); |
306 | 300 | ||
307 | dprintf("Sharing PLB.\n"); |
301 | dprintf("Sharing PLB.\n"); |
308 | 302 | ||
309 | futex_up(&fs_head_futex); |
- | |
310 | - | ||
311 | /* |
303 | /* |
312 | * That was it. The FS has been registered. |
304 | * That was it. The FS has been registered. |
313 | * In reply to the VFS_REGISTER request, we assign the client file |
305 | * In reply to the VFS_REGISTER request, we assign the client file |
314 | * system a global file system handle. |
306 | * system a global file system handle. |
315 | */ |
307 | */ |
316 | fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next); |
308 | fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next); |
317 | ipc_answer_fast(rid, EOK, (ipcarg_t) fs_info->fs_handle, 0); |
309 | ipc_answer_fast(rid, EOK, (ipcarg_t) fs_info->fs_handle, 0); |
- | 310 | ||
- | 311 | futex_up(&fs_head_futex); |
|
- | 312 | ||
318 | dprintf("\"%s\" filesystem successfully registered, handle=%d.\n", |
313 | dprintf("\"%s\" filesystem successfully registered, handle=%d.\n", |
319 | fs_info->vfs_info.name, fs_info->fs_handle); |
314 | fs_info->vfs_info.name, fs_info->fs_handle); |
320 | 315 | ||
321 | } |
316 | } |
322 | 317 | ||
Line 382... | Line 377... | ||
382 | * Not good to get here. |
377 | * Not good to get here. |
383 | */ |
378 | */ |
384 | assert(found == true); |
379 | assert(found == true); |
385 | } |
380 | } |
386 | 381 | ||
- | 382 | /** Convert file system name to its handle. |
|
- | 383 | * |
|
- | 384 | * @param name File system name. |
|
- | 385 | * @param lock If true, the function will down and up the |
|
- | 386 | * fs_head_futex. |
|
- | 387 | * |
|
- | 388 | * @return File system handle or zero if file system not found. |
|
- | 389 | */ |
|
- | 390 | int fs_name_to_handle(char *name, bool lock) |
|
- | 391 | { |
|
- | 392 | int handle = 0; |
|
- | 393 | ||
- | 394 | if (lock) |
|
- | 395 | futex_down(&fs_head_futex); |
|
- | 396 | link_t *cur; |
|
- | 397 | for (cur = fs_head.next; cur != &fs_head; cur = cur->next) { |
|
- | 398 | fs_info_t *fs = list_get_instance(cur, fs_info_t, fs_link); |
|
- | 399 | if (strcmp(fs->vfs_info.name, name) == 0) { /* XXX: strncmp() */ |
|
- | 400 | handle = fs->fs_handle; |
|
- | 401 | break; |
|
- | 402 | } |
|
- | 403 | } |
|
- | 404 | if (lock) |
|
- | 405 | futex_up(&fs_head_futex); |
|
- | 406 | return handle; |
|
- | 407 | } |
|
- | 408 | ||
387 | /** |
409 | /** |
388 | * @} |
410 | * @} |
389 | */ |
411 | */ |