GCC Code Coverage Report


Directory: common/src/
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 100.0% 11 / 0 / 11
Functions: 100.0% 1 / 0 / 1
Branches: 100.0% 2 / 0 / 2

fx_fault_tolerant_write_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_directory.h"
28 #include "fx_fault_tolerant.h"
29
30
31 #ifdef FX_ENABLE_FAULT_TOLERANT
32 /**************************************************************************/
33 /* */
34 /* FUNCTION RELEASE */
35 /* */
36 /* _fx_fault_tolerant_write_log_file PORTABLE C */
37 /* 6.1 */
38 /* AUTHOR */
39 /* */
40 /* William E. Lamie, Microsoft Corporation */
41 /* */
42 /* DESCRIPTION */
43 /* */
44 /* This function writes data of one sector of fault tolerant data */
45 /* from memory to log file in file system. */
46 /* */
47 /* INPUT */
48 /* */
49 /* media_ptr Media control block pointer */
50 /* relative_sector Relative sector number of the */
51 /* log file to write to */
52 /* */
53 /* OUTPUT */
54 /* */
55 /* return status */
56 /* */
57 /* CALLS */
58 /* */
59 /* _fx_utility_logical_sector_write Write a logical sector */
60 /* _fx_utility_logical_sector_flush Flush written logical sectors */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* _fx_fault_tolerant_cleanup_FAT_chain */
65 /* _fx_fault_tolerant_reset_log_file */
66 /* _fx_fault_tolerant_set_FAT_chain */
67 /* _fx_fault_tolerant_transaction_end */
68 /* */
69 /**************************************************************************/
70 333441623 UINT _fx_fault_tolerant_write_log_file(FX_MEDIA *media_ptr, ULONG relative_sector)
71 {
72 UINT status;
73 ULONG start_sector;
74
75 /* Calculate the start sector of log file. */
76 333441623 start_sector = (media_ptr -> fx_media_fault_tolerant_start_cluster - FX_FAT_ENTRY_START) *
77 333441623 media_ptr -> fx_media_sectors_per_cluster +
78 333441623 media_ptr -> fx_media_data_sector_start;
79
80
81 /* Write sector directly. */
82 333441623 status = _fx_utility_logical_sector_write(media_ptr, (ULONG64) (start_sector + relative_sector),
83 333441623 media_ptr -> fx_media_fault_tolerant_memory_buffer +
84 333441623 media_ptr -> fx_media_bytes_per_sector * relative_sector,
85 ((ULONG) 1), FX_DATA_SECTOR);
86
87 /* Check for a bad status. */
88
2/2
✓ Branch 3 → 4 taken 42 times.
✓ Branch 3 → 5 taken 333441164 times.
333441206 if (status != FX_SUCCESS)
89 {
90
91 /* Return the bad status. */
92 42 return(status);
93 }
94
95 /* Flush the internal logical sector cache. */
96 333441164 status = _fx_utility_logical_sector_flush(media_ptr, (ULONG64) start_sector, ((ULONG64) 1), FX_FALSE);
97
98 FX_FAULT_TOLERANT_WRITE_LOG_FILE_EXTENSION
99
100 /* Return the status. */
101 333441164 return(status);
102 }
103 #endif /* FX_ENABLE_FAULT_TOLERANT */
104
105