Changeset 808 for soft/giet_vm
- Timestamp:
- Mar 17, 2016, 2:18:30 PM (9 years ago)
- Location:
- soft/giet_vm/giet_fat32
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r807 r808 2409 2409 2410 2410 // get flags 2411 unsigned int create = ((flags & O_CREAT) != 0); 2412 unsigned int read_only = ((flags & O_RDONLY) != 0); 2413 unsigned int truncate = ((flags & O_TRUNC) != 0); 2414 unsigned int append = ((flags & O_APPEND) != 0); 2411 unsigned int create = ((flags & O_CREAT) != 0); 2412 unsigned int read_only = ((flags & O_RDONLY) != 0); 2413 unsigned int write_only = ((flags & O_WRONLY) != 0); 2414 unsigned int truncate = ((flags & O_TRUNC) != 0); 2415 unsigned int append = ((flags & O_APPEND) != 0); 2415 2416 2416 2417 #if GIET_DEBUG_FAT … … 2623 2624 _fat.fd[fd_id].allocated = 1; 2624 2625 _fat.fd[fd_id].read_only = read_only; 2626 _fat.fd[fd_id].write_only = write_only; 2625 2627 _fat.fd[fd_id].inode = child; 2626 2628 _fat.fd[fd_id].seek = ( append ) ? child->size : 0; … … 2821 2823 } 2822 2824 2823 // check fd_id overflow2824 if ( fd_id >= GIET_OPEN_FILES_MAX )2825 {2826 _printf("\n[FAT ERROR] in _fat_read(): illegal file descriptor\n");2827 return GIET_FAT32_INVALID_FD;2828 }2829 2830 // check file open2831 if ( _fat.fd[fd_id].allocated == 0 )2832 {2833 _printf("\n[FAT ERROR] in _fat_read(): file not open\n");2834 return GIET_FAT32_NOT_OPEN;2835 }2836 2837 2825 // takes the FAT lock and register it in thread context 2838 2826 static_scheduler_t* psched = _get_sched(); … … 2841 2829 _atomic_or( &psched->context[ltid].slot[CTX_LOCKS_ID] , LOCKS_MASK_FAT ); 2842 2830 2831 // check fd_id overflow 2832 if ( fd_id >= GIET_OPEN_FILES_MAX ) 2833 { 2834 _spin_lock_release( &_fat.fat_lock ); 2835 _atomic_and( &psched->context[ltid].slot[CTX_LOCKS_ID] , ~LOCKS_MASK_FAT ); 2836 2837 _printf("\n[FAT ERROR] in _fat_read(): illegal file descriptor\n"); 2838 return GIET_FAT32_INVALID_FD; 2839 } 2840 2841 // check file open 2842 if ( _fat.fd[fd_id].allocated == 0 ) 2843 { 2844 _spin_lock_release( &_fat.fat_lock ); 2845 _atomic_and( &psched->context[ltid].slot[CTX_LOCKS_ID] , ~LOCKS_MASK_FAT ); 2846 2847 _printf("\n[FAT ERROR] in _fat_read(): file not open\n"); 2848 return GIET_FAT32_NOT_OPEN; 2849 } 2850 2851 // check file readable 2852 if ( _fat.fd[fd_id].write_only ) 2853 { 2854 _spin_lock_release( &_fat.fat_lock ); 2855 _atomic_and( &psched->context[ltid].slot[CTX_LOCKS_ID] , ~LOCKS_MASK_FAT ); 2856 2857 _printf("\n[FAT ERROR] _fat_read(): file <%s> is write-only\n", 2858 _fat.fd[fd_id].inode->name ); 2859 return GIET_FAT32_WRITE_ONLY; 2860 } 2861 2843 2862 // get special modes 2844 2863 unsigned int physical_addressing = modes & FAT_PADDR_MODE; -
soft/giet_vm/giet_fat32/fat32.h
r787 r808 186 186 char allocated; // file descriptor allocated 187 187 char read_only; // write protected 188 char reserved[6]; // reserved 188 char write_only; // read protected 189 char reserved[5]; // reserved 189 190 } fat_file_desc_t; 190 191 -
soft/giet_vm/giet_fat32/fat32_shared.h
r807 r808 37 37 38 38 #define O_RDONLY 0x01 39 #define O_WRONLY 0x02 40 #define O_RDWR 0x00 39 41 #define O_TRUNC 0x10 40 42 #define O_CREAT 0x20 … … 83 85 #define GIET_FAT32_NO_MORE_ENTRIES (-18) 84 86 #define GIET_FAT32_BUFFER_TOO_SMALL (-19) 87 #define GIET_FAT32_WRITE_ONLY (-20) 85 88 86 89 #endif // _FAT32_SHARED
Note: See TracChangeset
for help on using the changeset viewer.