- Timestamp:
- Mar 2, 2016, 2:26:49 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_fat32/fat32.c
r787 r797 686 686 687 687 688 /////////////////////////////////////////////////////////////// ////688 /////////////////////////////////////////////////////////////// 689 689 static unsigned int _get_free_cluster( unsigned int* cluster ) 690 690 { … … 932 932 static unsigned int _cluster_release( unsigned int cluster ) 933 933 { 934 if ( cluster >= END_OF_CHAIN_CLUSTER_MIN ) // terminal case : nothing to do 935 { 936 return 0; 937 } 938 else // non terminal case : recursive call, then release cluster 934 if ( cluster < END_OF_CHAIN_CLUSTER_MIN ) // non terminal case 939 935 { 940 936 // get next cluster … … 942 938 if ( _get_fat_entry( cluster , &next ) ) 943 939 { 944 _printf("\n[FAT ERROR] in _cluster_release() accessing Fat-Cache"940 _printf("\n[FAT ERROR] in _cluster_release() scanning Fat-Cache" 945 941 " for cluster %x\n", cluster ); 946 942 return 1; 947 943 } 948 944 949 // call _cluster_release() on next 945 // call _cluster_release() on next cluster 950 946 if ( _cluster_release( next ) ) return 1; 951 952 // release current cluster 953 if ( _set_fat_entry( cluster , FREE_CLUSTER ) ) 954 { 955 _printf("\n[FAT ERROR] in _cluster_release() updating Fat-Cache" 956 " for cluster %x\n", cluster ); 957 return 1; 958 } 959 960 // update free_cluster _hint and free_clusters_number in FAT descriptor 961 _fat.free_clusters_number++; 962 if ( cluster < _fat.free_cluster_hint ) _fat.free_cluster_hint = cluster; 963 964 return 0; 965 } 947 } 948 949 // In both cases (terminal or not) release cluster 950 if ( _set_fat_entry( cluster , FREE_CLUSTER ) ) 951 { 952 _printf("\n[FAT ERROR] in _cluster_release() updating Fat-Cache" 953 " for cluster %x\n", cluster ); 954 return 1; 955 } 956 957 // Update free_cluster _hint and free_clusters_number in FAT descriptor 958 _fat.free_clusters_number++; 959 if ( cluster < _fat.free_cluster_hint ) _fat.free_cluster_hint = cluster; 960 961 return 0; 962 966 963 } // end _cluster_release() 967 964 … … 969 966 static unsigned int _all_clusters_release( fat_inode_t* inode ) 970 967 { 971 // release recursively all clusters in FAT chaining, 972 // starting from last cluster in chain, ending by first. 968 // release recursively all clusters in FAT chaining reverse order 969 // starting from last cluster in chain, ending by first. 970 973 971 if ( _cluster_release( inode->cluster ) ) 974 972 { … … 989 987 if ( _update_fs_info() ) 990 988 { 991 _printf("\n[FAT ERROR] in _all_clusters_release() updating FS_INFO sector on device\n");989 _printf("\n[FAT ERROR] in _all_clusters_release() updating FS_INFO sector\n"); 992 990 return 1; 993 991 } 992 993 // update cluster field in inode 994 inode->cluster = END_OF_CHAIN_CLUSTER_MIN; 994 995 995 996 #if GIET_DEBUG_FAT … … 2626 2627 { 2627 2628 // empty file 2628 child->size = 0;2629 child->size = 0; 2629 2630 child->levels = _get_levels_from_size( child->size ); 2630 2631
Note: See TracChangeset
for help on using the changeset viewer.