Changeset 317 for trunk/kernel/vfs
- Timestamp:
- Aug 4, 2017, 2:03:44 PM (7 years ago)
- Location:
- trunk/kernel/vfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/vfs.c
r315 r317 662 662 } // end vfs_open() 663 663 664 ////////////////////////////////////////// 664 //////////////////////////////////////////// 665 665 error_t vfs_user_move( bool_t to_buffer, 666 666 xptr_t file_xp, … … 722 722 } // end vfs_user_move() 723 723 724 //////////////////////////////////////////// 725 error_t vfs_kernel_move( bool_t to_buffer, 726 xptr_t file_xp, 727 xptr_t buffer_xp, 728 uint32_t size ) 729 { 730 assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" ); 731 732 cxy_t file_cxy; // remote file descriptor cluster 733 vfs_file_t * file_ptr; // remote file descriptor local pointer 734 vfs_inode_type_t inode_type; 735 uint32_t file_offset; // current offset in file 736 mapper_t * mapper; 737 error_t error; 738 739 // get cluster and local pointer on remote file descriptor 740 file_cxy = GET_CXY( file_xp ); 741 file_ptr = (vfs_file_t *)GET_PTR( file_xp ); 742 743 // get inode type from remote file descriptor 744 inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type ) ); 745 746 // action depends on inode type 747 if( inode_type == INODE_TYPE_FILE ) 748 { 749 // get mapper pointer and file offset from file descriptor 750 file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) ); 751 mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) ); 752 753 // move data between mapper and buffer 754 if( file_cxy == local_cxy ) 755 { 756 error = mapper_move_kernel( mapper, 757 to_buffer, 758 file_offset, 759 buffer_xp, 760 size ); 761 } 762 else 763 { 764 rpc_mapper_move_buffer_client( file_cxy, 765 mapper, 766 to_buffer, 767 false, // kernel buffer 768 file_offset, 769 buffer_xp, 770 size, 771 &error ); 772 } 773 774 if( error ) return -1; 775 else return 0; 776 } 777 else 778 { 779 printk("\n[ERROR] in %s : inode is not a file", __FUNCTION__ ); 780 return -1; 781 } 782 } // end vfs_kernel_move() 783 724 784 ////////////////////////////////////// 725 785 error_t vfs_lseek( xptr_t file_xp, -
trunk/kernel/vfs/vfs.h
r313 r317 735 735 * <file_xp> argument, and a - possibly distributed - user space <buffer>, taken into 736 736 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>. 737 * This function is called by the sys_read() and sys_write() system calls.737 * This function is called by the elf_load_process() function. 738 738 ****************************************************************************************** 739 739 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false. … … 741 741 * @ buffer : user space pointer on buffer (can be physically distributed). 742 742 * @ size : requested number of bytes from offset. 743 * @ returns number of bytes actually transfered/ -1 if error.743 * @ returns 0 f success / -1 if error. 744 744 *****************************************************************************************/ 745 745 error_t vfs_user_move( bool_t to_buffer, … … 747 747 void * buffer, 748 748 uint32_t size ); 749 750 /****************************************************************************************** 751 * This function moves <size> bytes between a remote file mapper, identified by the 752 * <file_xp> argument, and a - possibly remote - kernel <buffer_xp>, taken into 753 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>. 754 * This function is called by the system calls. 755 ****************************************************************************************** 756 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false. 757 * @ file_xp : extended pointer on the remote file descriptor. 758 * @ buffer_xp : user space pointer on buffer (can be physically distributed). 759 * @ size : requested number of bytes from offset. 760 * @ returns number of bytes actually transfered / -1 if error. 761 *****************************************************************************************/ 762 error_t vfs_kernel_move( bool_t to_buffer, 763 xptr_t file_xp, 764 xptr_t buffer_xp, 765 uint32_t size ); 749 766 750 767 /******************************************************************************************
Note: See TracChangeset
for help on using the changeset viewer.