Changeset ffa2c8ef in mainline for uspace/lib/fs/libfs.c
- Timestamp:
- 2011-01-29T11:36:08Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 46b881c
- Parents:
- 64d2b10
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/fs/libfs.c
r64d2b10 rffa2c8ef 40 40 #include <errno.h> 41 41 #include <async.h> 42 #include <ipc/ipc.h>43 42 #include <as.h> 44 43 #include <assert.h> … … 58 57 #define answer_and_return(rid, rc) \ 59 58 do { \ 60 ipc_answer_0((rid), (rc)); \59 async_answer_0((rid), (rc)); \ 61 60 return; \ 62 61 } while (0) … … 102 101 * Ask VFS for callback connection. 103 102 */ 104 sysarg_t taskhash; 105 ipc_connect_to_me(vfs_phone, 0, 0, 0, &taskhash, ®->vfs_phonehash); 103 async_connect_to_me(vfs_phone, 0, 0, 0, conn); 106 104 107 105 /* … … 128 126 async_wait_for(req, NULL); 129 127 reg->fs_handle = (int) IPC_GET_ARG1(answer); 130 131 /*132 * Create a connection fibril to handle the callback connection.133 */134 async_new_connection(taskhash, reg->vfs_phonehash, 0, NULL, conn);135 128 136 129 /* … … 166 159 if ((IPC_GET_IMETHOD(call) != IPC_M_CONNECTION_CLONE) || 167 160 (mountee_phone < 0)) { 168 ipc_answer_0(callid, EINVAL);169 ipc_answer_0(rid, EINVAL);161 async_answer_0(callid, EINVAL); 162 async_answer_0(rid, EINVAL); 170 163 return; 171 164 } 172 165 173 166 /* Acknowledge the mountee_phone */ 174 ipc_answer_0(callid, EOK);167 async_answer_0(callid, EOK); 175 168 176 169 fs_node_t *fn; 177 170 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 178 171 if ((res != EOK) || (!fn)) { 179 ipc_hangup(mountee_phone);172 async_hangup(mountee_phone); 180 173 async_data_write_void(combine_rc(res, ENOENT)); 181 ipc_answer_0(rid, combine_rc(res, ENOENT));174 async_answer_0(rid, combine_rc(res, ENOENT)); 182 175 return; 183 176 } 184 177 185 178 if (fn->mp_data.mp_active) { 186 ipc_hangup(mountee_phone);179 async_hangup(mountee_phone); 187 180 (void) ops->node_put(fn); 188 181 async_data_write_void(EBUSY); 189 ipc_answer_0(rid, EBUSY);182 async_answer_0(rid, EBUSY); 190 183 return; 191 184 } … … 193 186 rc = async_req_0_0(mountee_phone, IPC_M_CONNECT_ME); 194 187 if (rc != EOK) { 195 ipc_hangup(mountee_phone);188 async_hangup(mountee_phone); 196 189 (void) ops->node_put(fn); 197 190 async_data_write_void(rc); 198 ipc_answer_0(rid, rc);191 async_answer_0(rid, rc); 199 192 return; 200 193 } … … 214 207 * Do not release the FS node so that it stays in memory. 215 208 */ 216 ipc_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),209 async_answer_3(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer), 217 210 IPC_GET_ARG3(answer)); 218 211 } … … 227 220 res = ops->node_get(&fn, mp_devmap_handle, mp_fs_index); 228 221 if ((res != EOK) || (!fn)) { 229 ipc_answer_0(rid, combine_rc(res, ENOENT));222 async_answer_0(rid, combine_rc(res, ENOENT)); 230 223 return; 231 224 } … … 236 229 if (!fn->mp_data.mp_active) { 237 230 (void) ops->node_put(fn); 238 ipc_answer_0(rid, EINVAL);231 async_answer_0(rid, EINVAL); 239 232 return; 240 233 } … … 250 243 */ 251 244 if (res == EOK) { 252 ipc_hangup(fn->mp_data.phone);245 async_hangup(fn->mp_data.phone); 253 246 fn->mp_data.mp_active = false; 254 247 fn->mp_data.fs_handle = 0; … … 260 253 261 254 (void) ops->node_put(fn); 262 ipc_answer_0(rid, res);255 async_answer_0(rid, res); 263 256 } 264 257 … … 300 293 301 294 if (cur->mp_data.mp_active) { 302 ipc_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP,295 async_forward_slow(rid, cur->mp_data.phone, VFS_OUT_LOOKUP, 303 296 next, last, cur->mp_data.devmap_handle, lflag, index, 304 297 IPC_FF_ROUTE_FROM_ME); … … 324 317 if (len + 1 == NAME_MAX) { 325 318 /* Component length overflow */ 326 ipc_answer_0(rid, ENAMETOOLONG);319 async_answer_0(rid, ENAMETOOLONG); 327 320 goto out; 328 321 } … … 358 351 next--; 359 352 360 ipc_forward_slow(rid, tmp->mp_data.phone,353 async_forward_slow(rid, tmp->mp_data.phone, 361 354 VFS_OUT_LOOKUP, next, last, tmp->mp_data.devmap_handle, 362 355 lflag, index, IPC_FF_ROUTE_FROM_ME); … … 372 365 if (next <= last) { 373 366 /* There are unprocessed components */ 374 ipc_answer_0(rid, ENOENT);367 async_answer_0(rid, ENOENT); 375 368 goto out; 376 369 } … … 380 373 /* Request to create a new link */ 381 374 if (!ops->is_directory(cur)) { 382 ipc_answer_0(rid, ENOTDIR);375 async_answer_0(rid, ENOTDIR); 383 376 goto out; 384 377 } … … 398 391 if (lflag & L_CREATE) 399 392 (void) ops->destroy(fn); 400 ipc_answer_0(rid, rc);393 async_answer_0(rid, rc); 401 394 } else { 402 395 aoff64_t size = ops->size_get(fn); 403 ipc_answer_5(rid, fs_handle,396 async_answer_5(rid, fs_handle, 404 397 devmap_handle, 405 398 ops->index_get(fn), … … 410 403 } 411 404 } else 412 ipc_answer_0(rid, ENOSPC);405 async_answer_0(rid, ENOSPC); 413 406 414 407 goto out; 415 408 } 416 409 417 ipc_answer_0(rid, ENOENT);410 async_answer_0(rid, ENOENT); 418 411 goto out; 419 412 } … … 441 434 if (lflag & (L_CREATE | L_LINK)) { 442 435 if (!ops->is_directory(cur)) { 443 ipc_answer_0(rid, ENOTDIR);436 async_answer_0(rid, ENOTDIR); 444 437 goto out; 445 438 } … … 450 443 if (ops->plb_get_char(next) == '/') { 451 444 /* More than one component */ 452 ipc_answer_0(rid, ENOENT);445 async_answer_0(rid, ENOENT); 453 446 goto out; 454 447 } … … 456 449 if (len + 1 == NAME_MAX) { 457 450 /* Component length overflow */ 458 ipc_answer_0(rid, ENAMETOOLONG);451 async_answer_0(rid, ENAMETOOLONG); 459 452 goto out; 460 453 } … … 480 473 if (lflag & L_CREATE) 481 474 (void) ops->destroy(fn); 482 ipc_answer_0(rid, rc);475 async_answer_0(rid, rc); 483 476 } else { 484 477 aoff64_t size = ops->size_get(fn); 485 ipc_answer_5(rid, fs_handle,478 async_answer_5(rid, fs_handle, 486 479 devmap_handle, 487 480 ops->index_get(fn), … … 492 485 } 493 486 } else 494 ipc_answer_0(rid, ENOSPC);487 async_answer_0(rid, ENOSPC); 495 488 496 489 goto out; 497 490 } 498 491 499 ipc_answer_0(rid, ENOENT);492 async_answer_0(rid, ENOENT); 500 493 goto out; 501 494 } … … 510 503 if (rc == EOK) { 511 504 aoff64_t size = ops->size_get(cur); 512 ipc_answer_5(rid, fs_handle, devmap_handle,505 async_answer_5(rid, fs_handle, devmap_handle, 513 506 ops->index_get(cur), LOWER32(size), UPPER32(size), 514 507 old_lnkcnt); 515 508 } else 516 ipc_answer_0(rid, rc);509 async_answer_0(rid, rc); 517 510 518 511 goto out; … … 521 514 if (((lflag & (L_CREATE | L_EXCLUSIVE)) == (L_CREATE | L_EXCLUSIVE)) || 522 515 (lflag & L_LINK)) { 523 ipc_answer_0(rid, EEXIST);516 async_answer_0(rid, EEXIST); 524 517 goto out; 525 518 } 526 519 527 520 if ((lflag & L_FILE) && (ops->is_directory(cur))) { 528 ipc_answer_0(rid, EISDIR);521 async_answer_0(rid, EISDIR); 529 522 goto out; 530 523 } 531 524 532 525 if ((lflag & L_DIRECTORY) && (ops->is_file(cur))) { 533 ipc_answer_0(rid, ENOTDIR);526 async_answer_0(rid, ENOTDIR); 534 527 goto out; 535 528 } 536 529 537 530 if ((lflag & L_ROOT) && par) { 538 ipc_answer_0(rid, EINVAL);531 async_answer_0(rid, EINVAL); 539 532 goto out; 540 533 } … … 548 541 if (rc == EOK) { 549 542 aoff64_t size = ops->size_get(cur); 550 ipc_answer_5(rid, fs_handle, devmap_handle,543 async_answer_5(rid, fs_handle, devmap_handle, 551 544 ops->index_get(cur), LOWER32(size), UPPER32(size), 552 545 ops->lnkcnt_get(cur)); 553 546 } else 554 ipc_answer_0(rid, rc);547 async_answer_0(rid, rc); 555 548 556 549 } else 557 ipc_answer_0(rid, rc);550 async_answer_0(rid, rc); 558 551 559 552 out: … … 584 577 (size != sizeof(struct stat))) { 585 578 ops->node_put(fn); 586 ipc_answer_0(callid, EINVAL);587 ipc_answer_0(rid, EINVAL);579 async_answer_0(callid, EINVAL); 580 async_answer_0(rid, EINVAL); 588 581 return; 589 582 } … … 604 597 605 598 async_data_read_finalize(callid, &stat, sizeof(struct stat)); 606 ipc_answer_0(rid, EOK);599 async_answer_0(rid, EOK); 607 600 } 608 601 … … 626 619 627 620 if (fn == NULL) { 628 ipc_answer_0(rid, ENOENT);621 async_answer_0(rid, ENOENT); 629 622 return; 630 623 } … … 632 625 rc = ops->node_open(fn); 633 626 aoff64_t size = ops->size_get(fn); 634 ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),627 async_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn), 635 628 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0)); 636 629
Note:
See TracChangeset
for help on using the changeset viewer.