Changeset 266 for trunk/kernel
- Timestamp:
- Jul 21, 2017, 1:51:24 PM (7 years ago)
- Location:
- trunk/kernel/vfs
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/vfs/vfs.c
r265 r266 718 718 uint32_t * new_offset ) 719 719 { 720 printk("\n[PANIC] %s non implemented\n", __FUNCTION__ ); 721 hal_core_sleep(); 722 return 0; 723 724 assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" ); 720 xptr_t offset_xp; 721 xptr_t lock_xp; 722 cxy_t file_cxy; 723 vfs_file_t * file_ptr; 724 vfs_inode_t * inode_ptr; 725 uint32_t new; 726 727 assert( (file_xp != XPTR_NULL) , __FUNCTION__ , "file_xp == XPTR_NULL" ); 728 729 // get cluster and local pointer on remote file descriptor 730 file_cxy = GET_CXY( file_xp ); 731 file_ptr = (vfs_file_t *)GET_PTR( file_xp ); 732 733 // build extended pointers on lock and offset 734 offset_xp = XPTR( file_cxy , &file_ptr->offset ); 735 lock_xp = XPTR( file_cxy , &file_ptr->lock ); 736 737 // take file descriptor lock 738 remote_rwlock_wr_lock( lock_xp ); 739 740 if ( whence == SEEK_CUR ) // new = current + offset 741 { 742 new = hal_remote_lw( offset_xp ) + offset; 743 } 744 else if ( whence == SEEK_SET ) // new = offset 745 { 746 new = offset; 747 } 748 else if ( whence == SEEK_END ) // new = size + offset 749 { 750 // get local pointer on remote inode 751 inode_ptr = (vfs_inode_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) ); 752 753 new = hal_remote_lw( XPTR( file_cxy , &inode_ptr->size ) ) + offset; 754 } 755 else 756 { 757 printk("\n[ERROR] in %s : illegal whence value\n", __FUNCTION__ ); 758 remote_rwlock_wr_unlock( lock_xp ); 759 return -1; 760 } 761 762 // set new offset 763 hal_remote_sw( offset_xp , new ); 764 765 // release file descriptor lock 766 remote_rwlock_wr_unlock( lock_xp ); 767 768 // success 769 *new_offset = new; 770 return 0; 725 771 726 772 } // vfs_lseek() -
trunk/kernel/vfs/vfs.h
r265 r266 229 229 * the inode, when a thread makes an open() or opendir() system call. 230 230 * It cannot exist a file structure without an inode structure. 231 * A a the fd_array (containing extended pointers on the open file descriptors)* is replicated in all process descriptors, we need a references counter.231 * As the fd_array (containing extended pointers on the open file descriptors) 232 232 * is replicated in all process descriptors, we need a references counter. 233 233 *****************************************************************************************/ 234 235 typedef enum 236 { 237 VFS_SEEK_SET, 238 VFS_SEEK_CUR, 239 VFS_SEEK_END, 240 } 241 vfs_lseek_cmd_t; 234 242 235 243 typedef enum
Note: See TracChangeset
for help on using the changeset viewer.