diff options
author | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2021-01-21 16:53:55 +0100 |
---|---|---|
committer | Christian Mauderer <christian.mauderer@embedded-brains.de> | 2021-03-26 14:25:56 +0100 |
commit | fd639b8abf1b82a74d14fbfe0180d853bbb43855 (patch) | |
tree | 15f3bb6e652d20ff17f84dabe87b194deb585287 /cpukit/libfs/src/dosfs/fat_file.c | |
parent | libblock: Add rtems_bdbuf_peek() (diff) | |
download | rtems-fd639b8abf1b82a74d14fbfe0180d853bbb43855.tar.bz2 |
dosfs: Use peek support
This speeds up reading fragmented files.
Fix #3689
Diffstat (limited to '')
-rw-r--r-- | cpukit/libfs/src/dosfs/fat_file.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/cpukit/libfs/src/dosfs/fat_file.c b/cpukit/libfs/src/dosfs/fat_file.c index b4af8a11ca..ef9df0a67c 100644 --- a/cpukit/libfs/src/dosfs/fat_file.c +++ b/cpukit/libfs/src/dosfs/fat_file.c @@ -301,8 +301,11 @@ fat_file_read( uint32_t ofs = 0; uint32_t save_ofs; uint32_t sec = 0; + uint32_t sec_peek = 0; uint32_t byte = 0; uint32_t c = 0; + uint32_t blk = 0; + uint32_t blk_cnt = 0; /* it couldn't be removed - otherwise cache update will be broken */ if (count == 0) @@ -345,19 +348,27 @@ fat_file_read( c = MIN(count, (fs_info->vol.bpc - ofs)); sec = fat_cluster_num_to_sector_num(fs_info, cur_cln); + + save_cln = cur_cln; + rc = fat_get_fat_cluster(fs_info, cur_cln, &cur_cln); + if ( rc != RC_OK ) + return rc; + + sec_peek = fat_cluster_num_to_sector_num(fs_info, cur_cln); + blk = fat_sector_num_to_block_num (fs_info, sec_peek); + blk_cnt = fs_info->vol.bpc >> fs_info->vol.bytes_per_block_log2; + if (blk_cnt == 0) + blk_cnt = 1; + fat_block_peek(fs_info, blk, blk_cnt); + sec += (ofs >> fs_info->vol.sec_log2); byte = ofs & (fs_info->vol.bps - 1); - ret = _fat_block_read(fs_info, sec, byte, c, buf + cmpltd); if ( ret < 0 ) return -1; count -= c; cmpltd += c; - save_cln = cur_cln; - rc = fat_get_fat_cluster(fs_info, cur_cln, &cur_cln); - if ( rc != RC_OK ) - return rc; ofs = 0; } |