GCC Code Coverage Report


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

fx_fault_tolerant_transaction_start.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_fault_tolerant.h"
27
28
29 #ifdef FX_ENABLE_FAULT_TOLERANT
30 /**************************************************************************/
31 /* */
32 /* FUNCTION RELEASE */
33 /* */
34 /* _fx_fault_tolerant_transaction_start PORTABLE C */
35 /* 6.1 */
36 /* AUTHOR */
37 /* */
38 /* William E. Lamie, Microsoft Corporation */
39 /* */
40 /* DESCRIPTION */
41 /* */
42 /* This function is called at the beginning of an update to FileX */
43 /* file, directory entry, or FAT table. It resets fault tolerant */
44 /* internal state information. */
45 /* */
46 /* INPUT */
47 /* */
48 /* media_ptr Media control block pointer */
49 /* */
50 /* OUTPUT */
51 /* */
52 /* return status */
53 /* */
54 /* CALLS */
55 /* */
56 /* None */
57 /* */
58 /* CALLED BY */
59 /* */
60 /* _fx_directory_attributes_set */
61 /* _fx_directory_create */
62 /* _fx_directory_delete */
63 /* _fx_directory_rename */
64 /* _fx_file_allocate */
65 /* _fx_file_attributes_set */
66 /* _fx_file_best_effort_allocate */
67 /* _fx_file_create */
68 /* _fx_file_delete */
69 /* _fx_file_rename */
70 /* _fx_file_truncate */
71 /* _fx_file_truncate_release */
72 /* _fx_file_write */
73 /* _fx_unicode_directory_create */
74 /* _fx_unicode_file_create */
75 /* */
76 /**************************************************************************/
77 162909389 UINT _fx_fault_tolerant_transaction_start(FX_MEDIA *media_ptr)
78 {
79
80 /* Is fault tolerant enabled? */
81
2/2
✓ Branch 2 → 3 taken 160146299 times.
✓ Branch 2 → 6 taken 2763090 times.
162909389 if (media_ptr -> fx_media_fault_tolerant_enabled == FX_TRUE)
82 {
83
84 /* Is this a new transaction? */
85
2/2
✓ Branch 3 → 4 taken 160144703 times.
✓ Branch 3 → 5 taken 1596 times.
160146299 if (media_ptr -> fx_media_fault_tolerant_transaction_count == 0)
86 {
87
88 /* Yes. Initialize data. */
89 160144703 media_ptr -> fx_media_fault_tolerant_file_size = FX_FAULT_TOLERANT_LOG_HEADER_SIZE +
90 FX_FAULT_TOLERANT_FAT_CHAIN_SIZE +
91 FX_FAULT_TOLERANT_LOG_CONTENT_HEADER_SIZE;
92
93 /* Reset total logs. */
94 160144703 media_ptr -> fx_media_fault_tolerant_total_logs = 0;
95
96 /* Set state of fault tolerant. */
97 160144703 media_ptr -> fx_media_fault_tolerant_state = FX_FAULT_TOLERANT_STATE_STARTED;
98 }
99
100 /* Increase the transaction. */
101 160146299 media_ptr -> fx_media_fault_tolerant_transaction_count++;
102 }
103
104 162909389 return(FX_SUCCESS);
105 }
106 #endif /* FX_ENABLE_FAULT_TOLERANT */
107
108