Changes in uspace/srv/fs/devfs/devfs_ops.c [79ae36dd:efcebe1] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/devfs/devfs_ops.c
r79ae36dd refcebe1 403 403 } 404 404 405 static char devfs_plb_get_char(unsigned pos)406 {407 return devfs_reg.plb_ro[pos % PLB_SIZE];408 }409 410 405 static bool devfs_is_directory(fs_node_t *fn) 411 406 { … … 447 442 .size_get = devfs_size_get, 448 443 .lnkcnt_get = devfs_lnkcnt_get, 449 .plb_get_char = devfs_plb_get_char,450 444 .is_directory = devfs_is_directory, 451 445 .is_file = devfs_is_file, … … 462 456 } 463 457 464 void devfs_mounted(ipc_callid_t rid, ipc_call_t *request) 465 { 466 char *opts; 467 468 /* Accept the mount options */ 469 sysarg_t retval = async_data_write_accept((void **) &opts, true, 0, 0, 470 0, NULL); 471 if (retval != EOK) { 472 async_answer_0(rid, retval); 473 return; 474 } 475 476 free(opts); 477 async_answer_3(rid, EOK, 0, 0, 0); 478 } 479 480 void devfs_mount(ipc_callid_t rid, ipc_call_t *request) 481 { 482 libfs_mount(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request); 483 } 484 485 void devfs_unmounted(ipc_callid_t rid, ipc_call_t *request) 486 { 487 async_answer_0(rid, ENOTSUP); 488 } 489 490 void devfs_unmount(ipc_callid_t rid, ipc_call_t *request) 491 { 492 libfs_unmount(&devfs_libfs_ops, rid, request); 493 } 494 495 void devfs_lookup(ipc_callid_t rid, ipc_call_t *request) 496 { 497 libfs_lookup(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request); 498 } 499 500 void devfs_open_node(ipc_callid_t rid, ipc_call_t *request) 501 { 502 libfs_open_node(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request); 503 } 504 505 void devfs_stat(ipc_callid_t rid, ipc_call_t *request) 506 { 507 libfs_stat(&devfs_libfs_ops, devfs_reg.fs_handle, rid, request); 508 } 509 510 void devfs_read(ipc_callid_t rid, ipc_call_t *request) 511 { 512 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 513 aoff64_t pos = 514 (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request)); 515 458 static int devfs_mounted(devmap_handle_t devmap_handle, const char *opts, 459 fs_index_t *index, aoff64_t *size, unsigned *lnkcnt) 460 { 461 *index = 0; 462 *size = 0; 463 *lnkcnt = 0; 464 return EOK; 465 } 466 467 static int devfs_unmounted(devmap_handle_t devmap_handle) 468 { 469 return ENOTSUP; 470 } 471 472 static int 473 devfs_read(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos, 474 size_t *rbytes) 475 { 516 476 if (index == 0) { 517 477 ipc_callid_t callid; … … 519 479 if (!async_data_read_receive(&callid, &size)) { 520 480 async_answer_0(callid, EINVAL); 521 async_answer_0(rid, EINVAL); 522 return; 481 return EINVAL; 523 482 } 524 483 … … 540 499 async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1); 541 500 free(desc); 542 async_answer_1(rid, EOK, 1);543 return ;501 *rbytes = 1; 502 return EOK; 544 503 } 545 504 … … 555 514 async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1); 556 515 free(desc); 557 async_answer_1(rid, EOK, 1);558 return ;516 *rbytes = 1; 517 return EOK; 559 518 } 560 519 … … 563 522 564 523 async_answer_0(callid, ENOENT); 565 async_answer_1(rid, ENOENT, 0); 566 return; 524 return ENOENT; 567 525 } 568 526 … … 575 533 if (!async_data_read_receive(&callid, &size)) { 576 534 async_answer_0(callid, EINVAL); 577 async_answer_0(rid, EINVAL); 578 return; 535 return EINVAL; 579 536 } 580 537 … … 585 542 async_data_read_finalize(callid, desc[pos].name, str_size(desc[pos].name) + 1); 586 543 free(desc); 587 async_answer_1(rid, EOK, 1);588 return ;544 *rbytes = 1; 545 return EOK; 589 546 } 590 547 591 548 free(desc); 592 549 async_answer_0(callid, ENOENT); 593 async_answer_1(rid, ENOENT, 0); 594 return; 550 return ENOENT; 595 551 } 596 552 … … 606 562 if (lnk == NULL) { 607 563 fibril_mutex_unlock(&devices_mutex); 608 async_answer_0(rid, ENOENT); 609 return; 564 return ENOENT; 610 565 } 611 566 … … 617 572 fibril_mutex_unlock(&devices_mutex); 618 573 async_answer_0(callid, EINVAL); 619 async_answer_0(rid, EINVAL); 620 return; 574 return EINVAL; 621 575 } 622 576 … … 625 579 626 580 ipc_call_t answer; 627 aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request), 628 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 629 IPC_GET_ARG3(*request), &answer); 581 aid_t msg = async_send_4(exch, VFS_OUT_READ, devmap_handle, 582 index, LOWER32(pos), UPPER32(pos), &answer); 630 583 631 584 /* Forward the IPC_M_DATA_READ request to the driver */ … … 639 592 sysarg_t rc; 640 593 async_wait_for(msg, &rc); 641 size_t bytes = IPC_GET_ARG1(answer); 642 643 /* Driver reply is the final result of the whole operation */ 644 async_answer_1(rid, rc, bytes); 645 return; 646 } 647 648 async_answer_0(rid, ENOENT); 649 } 650 651 void devfs_write(ipc_callid_t rid, ipc_call_t *request) 652 { 653 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 654 if (index == 0) { 655 async_answer_0(rid, ENOTSUP); 656 return; 657 } 594 595 *rbytes = IPC_GET_ARG1(answer); 596 return rc; 597 } 598 599 return ENOENT; 600 } 601 602 static int 603 devfs_write(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t pos, 604 size_t *wbytes, aoff64_t *nsize) 605 { 606 if (index == 0) 607 return ENOTSUP; 658 608 659 609 devmap_handle_type_t type = devmap_handle_probe(index); … … 661 611 if (type == DEV_HANDLE_NAMESPACE) { 662 612 /* Namespace directory */ 663 async_answer_0(rid, ENOTSUP); 664 return; 613 return ENOTSUP; 665 614 } 666 615 … … 675 624 if (lnk == NULL) { 676 625 fibril_mutex_unlock(&devices_mutex); 677 async_answer_0(rid, ENOENT); 678 return; 626 return ENOENT; 679 627 } 680 628 … … 686 634 fibril_mutex_unlock(&devices_mutex); 687 635 async_answer_0(callid, EINVAL); 688 async_answer_0(rid, EINVAL); 689 return; 636 return EINVAL; 690 637 } 691 638 … … 694 641 695 642 ipc_call_t answer; 696 aid_t msg = async_send_3(exch, IPC_GET_IMETHOD(*request), 697 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), 698 IPC_GET_ARG3(*request), &answer); 643 aid_t msg = async_send_4(exch, VFS_OUT_WRITE, devmap_handle, 644 index, LOWER32(pos), UPPER32(pos), &answer); 699 645 700 646 /* Forward the IPC_M_DATA_WRITE request to the driver */ … … 708 654 sysarg_t rc; 709 655 async_wait_for(msg, &rc); 710 size_t bytes = IPC_GET_ARG1(answer); 711 712 /* Driver reply is the final result of the whole operation */ 713 async_answer_1(rid, rc, bytes); 714 return; 715 } 716 717 async_answer_0(rid, ENOENT); 718 } 719 720 void devfs_truncate(ipc_callid_t rid, ipc_call_t *request) 721 { 722 async_answer_0(rid, ENOTSUP); 723 } 724 725 void devfs_close(ipc_callid_t rid, ipc_call_t *request) 726 { 727 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 728 729 if (index == 0) { 730 async_answer_0(rid, EOK); 731 return; 732 } 656 657 *wbytes = IPC_GET_ARG1(answer); 658 *nsize = 0; 659 return rc; 660 } 661 662 return ENOENT; 663 } 664 665 static int 666 devfs_truncate(devmap_handle_t devmap_handle, fs_index_t index, aoff64_t size) 667 { 668 return ENOTSUP; 669 } 670 671 static int devfs_close(devmap_handle_t devmap_handle, fs_index_t index) 672 { 673 if (index == 0) 674 return EOK; 733 675 734 676 devmap_handle_type_t type = devmap_handle_probe(index); … … 736 678 if (type == DEV_HANDLE_NAMESPACE) { 737 679 /* Namespace directory */ 738 async_answer_0(rid, EOK); 739 return; 680 return EOK; 740 681 } 741 682 … … 749 690 if (lnk == NULL) { 750 691 fibril_mutex_unlock(&devices_mutex); 751 async_answer_0(rid, ENOENT); 752 return; 692 return ENOENT; 753 693 } 754 694 … … 764 704 fibril_mutex_unlock(&devices_mutex); 765 705 766 async_answer_0(rid, EOK); 767 return; 768 } 769 770 async_answer_0(rid, ENOENT); 771 } 772 773 void devfs_sync(ipc_callid_t rid, ipc_call_t *request) 774 { 775 fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request); 776 777 if (index == 0) { 778 async_answer_0(rid, EOK); 779 return; 780 } 706 return EOK; 707 } 708 709 return ENOENT; 710 } 711 712 static int devfs_sync(devmap_handle_t devmap_handle, fs_index_t index) 713 { 714 if (index == 0) 715 return EOK; 781 716 782 717 devmap_handle_type_t type = devmap_handle_probe(index); … … 784 719 if (type == DEV_HANDLE_NAMESPACE) { 785 720 /* Namespace directory */ 786 async_answer_0(rid, EOK); 787 return; 721 return EOK; 788 722 } 789 723 … … 797 731 if (lnk == NULL) { 798 732 fibril_mutex_unlock(&devices_mutex); 799 async_answer_0(rid, ENOENT); 800 return; 733 return ENOENT; 801 734 } 802 735 … … 808 741 809 742 ipc_call_t answer; 810 aid_t msg = async_send_2(exch, IPC_GET_IMETHOD(*request),811 IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);743 aid_t msg = async_send_2(exch, VFS_OUT_SYNC, devmap_handle, 744 index, &answer); 812 745 813 746 async_exchange_end(exch); … … 819 752 async_wait_for(msg, &rc); 820 753 821 /* Driver reply is the final result of the whole operation */ 822 async_answer_0(rid, rc); 823 return; 824 } 825 826 async_answer_0(rid, ENOENT); 827 } 828 829 void devfs_destroy(ipc_callid_t rid, ipc_call_t *request) 830 { 831 async_answer_0(rid, ENOTSUP); 832 } 754 return rc; 755 } 756 757 return ENOENT; 758 } 759 760 static int devfs_destroy(devmap_handle_t devmap_handle, fs_index_t index) 761 { 762 return ENOTSUP; 763 } 764 765 vfs_out_ops_t devfs_ops = { 766 .mounted = devfs_mounted, 767 .unmounted = devfs_unmounted, 768 .read = devfs_read, 769 .write = devfs_write, 770 .truncate = devfs_truncate, 771 .close = devfs_close, 772 .destroy = devfs_destroy, 773 .sync = devfs_sync, 774 }; 833 775 834 776 /**
Note:
See TracChangeset
for help on using the changeset viewer.