Changeset 86ffa27f in mainline for uspace/srv/fs/locfs/locfs_ops.c
- Timestamp:
- 2011-08-07T11:21:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cc574511
- Parents:
- 15f3c3f (diff), e8067c0 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/locfs/locfs_ops.c
r15f3c3f r86ffa27f 404 404 } 405 405 406 static char locfs_plb_get_char(unsigned pos)407 {408 return locfs_reg.plb_ro[pos % PLB_SIZE];409 }410 411 406 static bool locfs_is_directory(fs_node_t *fn) 412 407 { … … 448 443 .size_get = locfs_size_get, 449 444 .lnkcnt_get = locfs_lnkcnt_get, 450 .plb_get_char = locfs_plb_get_char,451 445 .is_directory = locfs_is_directory, 452 446 .is_file = locfs_is_file, … … 463 457 } 464 458 465 void locfs_mounted(ipc_callid_t rid, ipc_call_t *request) 466 { 467 char *opts; 468 469 /* Accept the mount options */ 470 sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0, 471 0, NULL); 472 if (retval != EOK) { 473 async_answer_0(rid, retval); 474 return; 475 } 476 477 free(opts); 478 async_answer_3(rid, EOK, 0, 0, 0); 479 } 480 481 void locfs_mount(ipc_callid_t rid, ipc_call_t *request) 482 { 483 libfs_mount(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request); 484 } 485 486 void locfs_unmounted(ipc_callid_t rid, ipc_call_t *request) 487 { 488 async_answer_0(rid, ENOTSUP); 489 } 490 491 void locfs_unmount(ipc_callid_t rid, ipc_call_t *request) 492 { 493 libfs_unmount(&locfs_libfs_ops, rid, request); 494 } 495 496 void locfs_lookup(ipc_callid_t rid, ipc_call_t *request) 497 { 498 libfs_lookup(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request); 499 } 500 501 void locfs_open_node(ipc_callid_t rid, ipc_call_t *request) 502 { 503 libfs_open_node(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request); 504 } 505 506 void locfs_stat(ipc_callid_t rid, ipc_call_t *request) 507 { 508 libfs_stat(&locfs_libfs_ops, locfs_reg.fs_handle, rid, request); 509 } 510 511 void locfs_read(ipc_callid_t rid, ipc_call_t *request) 512 { 513 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 514 aoff64_t pos = 515 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 516 459 static int locfs_mounted(service_id_t service_id, const char *opts, 460 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 461 { 462 *index = 0; 463 *size = 0; 464 *lnkcnt = 0; 465 return EOK; 466 } 467 468 static int locfs_unmounted(service_id_t service_id) 469 { 470 return ENOTSUP; 471 } 472 473 static int 474 locfs_read(service_id_t service_id, fs_index_t index, aoff64_t pos, 475 size_t *rbytes) 476 { 517 477 if (index == 0) { 518 478 ipc_callid_t callid; … … 520 480 if (!async_data_read_receive(&callid, &size)) { 521 481 async_answer_0(callid, EINVAL); 522 async_answer_0(rid, EINVAL); 523 return; 482 return EINVAL; 524 483 } 525 484 … … 541 500 async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1); 542 501 free(desc); 543 async_answer_1(rid, EOK, 1);544 return ;502 *rbytes = 1; 503 return EOK; 545 504 } 546 505 … … 556 515 async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1); 557 516 free(desc); 558 async_answer_1(rid, EOK, 1);559 return ;517 *rbytes = 1; 518 return EOK; 560 519 } 561 520 … … 564 523 565 524 async_answer_0(callid, ENOENT); 566 async_answer_1(rid, ENOENT, 0); 567 return; 525 return ENOENT; 568 526 } 569 527 … … 576 534 if (!async_data_read_receive(&callid, &size)) { 577 535 async_answer_0(callid, EINVAL); 578 async_answer_0(rid, EINVAL); 579 return; 536 return EINVAL; 580 537 } 581 538 … … 586 543 async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1); 587 544 free(desc); 588 async_answer_1(rid, EOK, 1);589 return ;545 *rbytes = 1; 546 return EOK; 590 547 } 591 548 592 549 free(desc); 593 550 async_answer_0(callid, ENOENT); 594 async_answer_1(rid, ENOENT, 0); 595 return; 551 return ENOENT; 596 552 } 597 553 … … 607 563 if (lnk == NULL) { 608 564 fibril_mutex_unlock(&services_mutex); 609 async_answer_0(rid, ENOENT); 610 return; 565 return ENOENT; 611 566 } 612 567 … … 618 573 fibril_mutex_unlock(&services_mutex); 619 574 async_answer_0(callid, EINVAL); 620 async_answer_0(rid, EINVAL); 621 return; 575 return EINVAL; 622 576 } 623 577 … … 626 580 627 581 ipc_call_t answer; 628 aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request), 629 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 630 IPC_GET_ARG3(*request), &answer); 582 aid_t msg = async_send_4(exch, VFS_OUT_READ, service_id, 583 index, LOWER32(pos), UPPER32(pos), &answer); 631 584 632 585 /* Forward the IPC_M_DATA_READ request to the driver */ … … 640 593 sysarg_t rc; 641 594 async_wait_for(msg, &rc); 642 size_t bytes = IPC_GET_ARG1(answer); 643 644 /* Driver reply is the final result of the whole operation */ 645 async_answer_1(rid, rc, bytes); 646 return; 647 } 648 649 async_answer_0(rid, ENOENT); 650 } 651 652 void locfs_write(ipc_callid_t rid, ipc_call_t *request) 653 { 654 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 655 if (index == 0) { 656 async_answer_0(rid, ENOTSUP); 657 return; 658 } 595 596 *rbytes = IPC_GET_ARG1(answer); 597 return rc; 598 } 599 600 return ENOENT; 601 } 602 603 static int 604 locfs_write(service_id_t service_id, fs_index_t index, aoff64_t pos, 605 size_t *wbytes, aoff64_t *nsize) 606 { 607 if (index == 0) 608 return ENOTSUP; 659 609 660 610 loc_object_type_t type = loc_id_probe(index); … … 662 612 if (type == LOC_OBJECT_NAMESPACE) { 663 613 /* Namespace directory */ 664 async_answer_0(rid, ENOTSUP); 665 return; 614 return ENOTSUP; 666 615 } 667 616 … … 676 625 if (lnk == NULL) { 677 626 fibril_mutex_unlock(&services_mutex); 678 async_answer_0(rid, ENOENT); 679 return; 627 return ENOENT; 680 628 } 681 629 … … 687 635 fibril_mutex_unlock(&services_mutex); 688 636 async_answer_0(callid, EINVAL); 689 async_answer_0(rid, EINVAL); 690 return; 637 return EINVAL; 691 638 } 692 639 … … 695 642 696 643 ipc_call_t answer; 697 aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request), 698 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 699 IPC_GET_ARG3(*request), &answer); 644 aid_t msg = async_send_4(exch, VFS_OUT_WRITE, service_id, 645 index, LOWER32(pos), UPPER32(pos), &answer); 700 646 701 647 /* Forward the IPC_M_DATA_WRITE request to the driver */ … … 709 655 sysarg_t rc; 710 656 async_wait_for(msg, &rc); 711 size_t bytes = IPC_GET_ARG1(answer); 712 713 /* Driver reply is the final result of the whole operation */ 714 async_answer_1(rid, rc, bytes); 715 return; 716 } 717 718 async_answer_0(rid, ENOENT); 719 } 720 721 void locfs_truncate(ipc_callid_t rid, ipc_call_t *request) 722 { 723 async_answer_0(rid, ENOTSUP); 724 } 725 726 void locfs_close(ipc_callid_t rid, ipc_call_t *request) 727 { 728 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 729 730 if (index == 0) { 731 async_answer_0(rid, EOK); 732 return; 733 } 657 658 *wbytes = IPC_GET_ARG1(answer); 659 *nsize = 0; 660 return rc; 661 } 662 663 return ENOENT; 664 } 665 666 static int 667 locfs_truncate(service_id_t service_id, fs_index_t index, aoff64_t size) 668 { 669 return ENOTSUP; 670 } 671 672 static int locfs_close(service_id_t service_id, fs_index_t index) 673 { 674 if (index == 0) 675 return EOK; 734 676 735 677 loc_object_type_t type = loc_id_probe(index); … … 737 679 if (type == LOC_OBJECT_NAMESPACE) { 738 680 /* Namespace directory */ 739 async_answer_0(rid, EOK); 740 return; 681 return EOK; 741 682 } 742 683 … … 750 691 if (lnk == NULL) { 751 692 fibril_mutex_unlock(&services_mutex); 752 async_answer_0(rid, ENOENT); 753 return; 693 return ENOENT; 754 694 } 755 695 … … 765 705 fibril_mutex_unlock(&services_mutex); 766 706 767 async_answer_0(rid, EOK); 768 return; 769 } 770 771 async_answer_0(rid, ENOENT); 772 } 773 774 void locfs_sync(ipc_callid_t rid, ipc_call_t *request) 775 { 776 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 777 778 if (index == 0) { 779 async_answer_0(rid, EOK); 780 return; 781 } 707 return EOK; 708 } 709 710 return ENOENT; 711 } 712 713 static int locfs_sync(service_id_t service_id, fs_index_t index) 714 { 715 if (index == 0) 716 return EOK; 782 717 783 718 loc_object_type_t type = loc_id_probe(index); … … 785 720 if (type == LOC_OBJECT_NAMESPACE) { 786 721 /* Namespace directory */ 787 async_answer_0(rid, EOK); 788 return; 722 return EOK; 789 723 } 790 724 … … 798 732 if (lnk == NULL) { 799 733 fibril_mutex_unlock(&services_mutex); 800 async_answer_0(rid, ENOENT); 801 return; 734 return ENOENT; 802 735 } 803 736 … … 809 742 810 743 ipc_call_t answer; 811 aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request),812 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);744 aid_t msg = async_send_2(exch, VFS_OUT_SYNC, service_id, 745 index, &answer); 813 746 814 747 async_exchange_end(exch); … … 820 753 async_wait_for(msg, &rc); 821 754 822 /* Driver reply is the final result of the whole operation */ 823 async_answer_0(rid, rc); 824 return; 825 } 826 827 async_answer_0(rid, ENOENT); 828 } 829 830 void locfs_destroy(ipc_callid_t rid, ipc_call_t *request) 831 { 832 async_answer_0(rid, ENOTSUP); 833 } 755 return rc; 756 } 757 758 return ENOENT; 759 } 760 761 static int locfs_destroy(service_id_t service_id, fs_index_t index) 762 { 763 return ENOTSUP; 764 } 765 766 vfs_out_ops_t locfs_ops = { 767 .mounted = locfs_mounted, 768 .unmounted = locfs_unmounted, 769 .read = locfs_read, 770 .write = locfs_write, 771 .truncate = locfs_truncate, 772 .close = locfs_close, 773 .destroy = locfs_destroy, 774 .sync = locfs_sync, 775 }; 834 776 835 777 /**
Note:
See TracChangeset
for help on using the changeset viewer.