Changes in uspace/lib/fs/libfs.c [1b20da0:a35b458] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/fs/libfs.c
r1b20da0 ra35b458 86 86 errno_t rc; 87 87 vfs_fs_probe_info_t info; 88 88 89 89 ipc_callid_t callid; 90 90 size_t size; … … 95 95 return; 96 96 } 97 97 98 98 memset(&info, 0, sizeof(info)); 99 99 rc = vfs_out_ops->fsprobe(service_id, &info); … … 103 103 return; 104 104 } 105 105 106 106 async_data_read_finalize(callid, &info, sizeof(info)); 107 107 async_answer_0(rid, EOK); … … 113 113 char *opts; 114 114 errno_t rc; 115 115 116 116 /* Accept the mount options. */ 117 117 rc = async_data_write_accept((void **) &opts, true, 0, 0, 0, NULL); … … 268 268 if (node == NULL) 269 269 async_answer_0(rid, EINVAL); 270 270 271 271 bool children = false; 272 272 rc = libfs_ops->has_children(&children, node); 273 273 libfs_ops->node_put(node); 274 274 275 275 if (rc != EOK) 276 276 async_answer_0(rid, rc); … … 288 288 async_answer_0(iid, EOK); 289 289 } 290 290 291 291 while (true) { 292 292 ipc_call_t call; 293 293 ipc_callid_t callid = async_get_call(&call); 294 294 295 295 if (!IPC_GET_IMETHOD(call)) 296 296 return; 297 297 298 298 switch (IPC_GET_IMETHOD(call)) { 299 299 case VFS_OUT_FSPROBE: … … 372 372 * out-of-order, when it knows that the operation succeeded or failed. 373 373 */ 374 374 375 375 async_exch_t *exch = async_exchange_begin(sess); 376 376 377 377 ipc_call_t answer; 378 378 aid_t req = async_send_0(exch, VFS_IN_REGISTER, &answer); 379 379 380 380 /* 381 381 * Send our VFS info structure to VFS. 382 382 */ 383 383 errno_t rc = async_data_write_start(exch, info, sizeof(*info)); 384 384 385 385 if (rc != EOK) { 386 386 async_exchange_end(exch); … … 388 388 return rc; 389 389 } 390 390 391 391 /* 392 392 * Set VFS_OUT and libfs operations. … … 403 403 rc = async_create_callback_port(exch, INTERFACE_VFS_DRIVER_CB, 0, 0, 404 404 vfs_connection, NULL, &port); 405 405 406 406 /* 407 407 * Request sharing the Path Lookup Buffer with VFS. … … 413 413 return ENOMEM; 414 414 } 415 415 416 416 async_exchange_end(exch); 417 417 418 418 if (rc) { 419 419 async_forget(req); 420 420 return rc; 421 421 } 422 422 423 423 /* 424 424 * Pick up the answer for the request to the VFS_IN_REQUEST call. … … 426 426 async_wait_for(req, NULL); 427 427 reg.fs_handle = (int) IPC_GET_ARG1(answer); 428 428 429 429 /* 430 430 * Tell the async framework that other connections are to be handled by … … 432 432 */ 433 433 async_set_fallback_port_handler(vfs_connection, NULL); 434 434 435 435 return IPC_GET_RETVAL(answer); 436 436 } … … 451 451 unsigned pos = *ppos; 452 452 unsigned size = 0; 453 453 454 454 if (pos == last) { 455 455 *sz = 0; … … 460 460 if (c == '/') 461 461 pos++; 462 462 463 463 for (int i = 0; i <= NAME_MAX; i++) { 464 464 c = plb_get_char(pos); … … 480 480 size_t size; 481 481 ipc_callid_t wcall; 482 482 483 483 if (!async_data_write_receive(&wcall, &size)) 484 484 return ENOENT; … … 498 498 fs_index_t parent_index = IPC_GET_ARG2(*req); 499 499 fs_index_t child_index = IPC_GET_ARG3(*req); 500 500 501 501 char component[NAME_MAX + 1]; 502 502 errno_t rc = receive_fname(component); … … 512 512 return; 513 513 } 514 514 515 515 fs_node_t *child = NULL; 516 516 rc = ops->node_get(&child, parent_sid, child_index); … … 520 520 return; 521 521 } 522 522 523 523 rc = ops->link(parent, child, component); 524 524 ops->node_put(parent); … … 548 548 fs_index_t index = IPC_GET_ARG4(*req); 549 549 int lflag = IPC_GET_ARG5(*req); 550 550 551 551 // TODO: Validate flags. 552 552 553 553 unsigned next = first; 554 554 unsigned last = first + len; 555 555 556 556 char component[NAME_MAX + 1]; 557 557 errno_t rc; 558 558 559 559 fs_node_t *par = NULL; 560 560 fs_node_t *cur = NULL; 561 561 fs_node_t *tmp = NULL; 562 562 unsigned clen = 0; 563 563 564 564 rc = ops->node_get(&cur, service_id, index); 565 565 if (rc != EOK) { … … 567 567 goto out; 568 568 } 569 569 570 570 assert(cur != NULL); 571 571 572 572 /* Find the file and its parent. */ 573 573 574 574 unsigned last_next = 0; 575 575 576 576 while (next != last) { 577 577 if (cur == NULL) { … … 584 584 goto out; 585 585 } 586 586 587 587 last_next = next; 588 588 /* Collect the component */ … … 593 593 goto out; 594 594 } 595 595 596 596 if (clen == 0) { 597 597 /* The path is just "/". */ 598 598 break; 599 599 } 600 600 601 601 assert(component[clen] == 0); 602 602 603 603 /* Match the component */ 604 604 rc = ops->match(&tmp, cur, component); … … 607 607 goto out; 608 608 } 609 609 610 610 /* Descend one level */ 611 611 if (par) { … … 616 616 } 617 617 } 618 618 619 619 par = cur; 620 620 cur = tmp; 621 621 tmp = NULL; 622 622 } 623 623 624 624 /* At this point, par is either NULL or a directory. 625 625 * If cur is NULL, the looked up file does not exist yet. 626 626 */ 627 627 628 628 assert(par == NULL || ops->is_directory(par)); 629 629 assert(par != NULL || cur != NULL); 630 630 631 631 /* Check for some error conditions. */ 632 632 633 633 if (cur && (lflag & L_FILE) && (ops->is_directory(cur))) { 634 634 async_answer_0(rid, EISDIR); 635 635 goto out; 636 636 } 637 637 638 638 if (cur && (lflag & L_DIRECTORY) && (ops->is_file(cur))) { 639 639 async_answer_0(rid, ENOTDIR); 640 640 goto out; 641 641 } 642 642 643 643 /* Unlink. */ 644 644 645 645 if (lflag & L_UNLINK) { 646 646 if (!cur) { … … 652 652 goto out; 653 653 } 654 654 655 655 rc = ops->unlink(par, cur, component); 656 656 if (rc == EOK) { … … 665 665 goto out; 666 666 } 667 667 668 668 /* Create. */ 669 669 670 670 if (lflag & L_CREATE) { 671 671 if (cur && (lflag & L_EXCLUSIVE)) { … … 673 673 goto out; 674 674 } 675 675 676 676 if (!cur) { 677 677 rc = ops->create(&cur, service_id, … … 685 685 goto out; 686 686 } 687 687 688 688 rc = ops->link(par, cur, component); 689 689 if (rc != EOK) { … … 695 695 } 696 696 } 697 697 698 698 /* Return. */ 699 699 out1: … … 704 704 goto out; 705 705 } 706 706 707 707 async_answer_5(rid, EOK, fs_handle, ops->index_get(cur), 708 708 (ops->is_directory(cur) << 16) | last, LOWER32(ops->size_get(cur)), 709 709 UPPER32(ops->size_get(cur))); 710 710 711 711 out: 712 712 if (par) 713 713 (void) ops->node_put(par); 714 714 715 715 if (cur) 716 716 (void) ops->node_put(cur); 717 717 718 718 if (tmp) 719 719 (void) ops->node_put(tmp); … … 824 824 service_id_t service_id = IPC_GET_ARG1(*request); 825 825 fs_index_t index = IPC_GET_ARG2(*request); 826 826 827 827 fs_node_t *fn; 828 828 errno_t rc = ops->node_get(&fn, service_id, index); 829 829 on_error(rc, answer_and_return(rid, rc)); 830 830 831 831 if (fn == NULL) { 832 832 async_answer_0(rid, ENOENT); 833 833 return; 834 834 } 835 835 836 836 rc = ops->node_open(fn); 837 837 aoff64_t size = ops->size_get(fn); … … 840 840 (ops->is_file(fn) ? L_FILE : 0) | 841 841 (ops->is_directory(fn) ? L_DIRECTORY : 0)); 842 842 843 843 (void) ops->node_put(fn); 844 844 }
Note:
See TracChangeset
for help on using the changeset viewer.