fx_fault_tolerant_read_log_file.c
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | /*************************************************************************** | ||
| 2 | * Copyright (c) 2024 Microsoft Corporation | ||
| 3 | * Copyright (c) 2026-present Eclipse ThreadX contributors | ||
| 4 | * | ||
| 5 | * This program and the accompanying materials are made available under the | ||
| 6 | * terms of the MIT License which is available at | ||
| 7 | * https://opensource.org/licenses/MIT. | ||
| 8 | * | ||
| 9 | * SPDX-License-Identifier: MIT | ||
| 10 | **************************************************************************/ | ||
| 11 | |||
| 12 | |||
| 13 | /**************************************************************************/ | ||
| 14 | /**************************************************************************/ | ||
| 15 | /** */ | ||
| 16 | /** FileX Component */ | ||
| 17 | /** */ | ||
| 18 | /** Fault Tolerant */ | ||
| 19 | /** */ | ||
| 20 | /**************************************************************************/ | ||
| 21 | /**************************************************************************/ | ||
| 22 | |||
| 23 | #define FX_SOURCE_CODE | ||
| 24 | |||
| 25 | #include "fx_api.h" | ||
| 26 | #include "fx_utility.h" | ||
| 27 | #include "fx_fault_tolerant.h" | ||
| 28 | |||
| 29 | |||
| 30 | #ifdef FX_ENABLE_FAULT_TOLERANT | ||
| 31 | /**************************************************************************/ | ||
| 32 | /* */ | ||
| 33 | /* FUNCTION RELEASE */ | ||
| 34 | /* */ | ||
| 35 | /* _fx_fault_tolerant_read_log_file PORTABLE C */ | ||
| 36 | /* 6.1 */ | ||
| 37 | /* AUTHOR */ | ||
| 38 | /* */ | ||
| 39 | /* William E. Lamie, Microsoft Corporation */ | ||
| 40 | /* */ | ||
| 41 | /* DESCRIPTION */ | ||
| 42 | /* */ | ||
| 43 | /* This function reads the entire log file from file system into the */ | ||
| 44 | /* fault tolerant cache. */ | ||
| 45 | /* */ | ||
| 46 | /* INPUT */ | ||
| 47 | /* */ | ||
| 48 | /* media_ptr Media control block pointer */ | ||
| 49 | /* */ | ||
| 50 | /* OUTPUT */ | ||
| 51 | /* */ | ||
| 52 | /* return status */ | ||
| 53 | /* */ | ||
| 54 | /* CALLS */ | ||
| 55 | /* */ | ||
| 56 | /* _fx_utility_logical_sector_read Read a logical sector */ | ||
| 57 | /* */ | ||
| 58 | /* CALLED BY */ | ||
| 59 | /* */ | ||
| 60 | /* _fx_fault_tolerant_enable */ | ||
| 61 | /* */ | ||
| 62 | /**************************************************************************/ | ||
| 63 | 1166 | UINT _fx_fault_tolerant_read_log_file(FX_MEDIA *media_ptr) | |
| 64 | { | ||
| 65 | UINT status; | ||
| 66 | ULONG sectors; | ||
| 67 | ULONG start_sector; | ||
| 68 | |||
| 69 | /* Calculate count of sectors to read. */ | ||
| 70 | 1166 | sectors = media_ptr -> fx_media_fault_tolerant_memory_buffer_size / media_ptr -> fx_media_bytes_per_sector; | |
| 71 | |||
| 72 | /* Calculate the start sector of log file. */ | ||
| 73 | 1166 | start_sector = (media_ptr -> fx_media_fault_tolerant_start_cluster - FX_FAT_ENTRY_START) * | |
| 74 | 1166 | media_ptr -> fx_media_sectors_per_cluster + | |
| 75 | 1166 | media_ptr -> fx_media_data_sector_start; | |
| 76 | |||
| 77 | 1166 | status = _fx_utility_logical_sector_read(media_ptr, (ULONG64) start_sector, | |
| 78 | 1166 | media_ptr -> fx_media_fault_tolerant_memory_buffer, | |
| 79 | sectors, FX_DATA_SECTOR); | ||
| 80 | |||
| 81 | /* Return the status. */ | ||
| 82 | 1166 | return(status); | |
| 83 | } | ||
| 84 | #endif /* FX_ENABLE_FAULT_TOLERANT */ | ||
| 85 | |||
| 86 |