Select one of the symbols to view example projects that use it.
 
Outline
...
...
...
...
#define FX_SOURCE_CODE
#include "fx_api.h"
#include "fx_utility.h"
#include "fx_fault_tolerant.h"
...
Files
loading...
SourceVuSTM32 Libraries and Samplesfilexcommon/src/fx_fault_tolerant_read_directory_sector.c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
/**************************************************************************/ /* */ /* Copyright (c) Microsoft Corporation. All rights reserved. */ /* */ /* This software is licensed under the Microsoft Software License */ /* Terms for Microsoft Azure RTOS. Full text of the license can be */ /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ /* and in the root directory of this software. */ /* */... /**************************************************************************/ ... /**************************************************************************/ /**************************************************************************/ /** */ /** FileX Component */ /** */ /** Fault Tolerant */ /** */... /**************************************************************************/ /**************************************************************************/ #define FX_SOURCE_CODE #include "fx_api.h" #include "fx_utility.h" #include "fx_fault_tolerant.h" #ifdef FX_ENABLE_FAULT_TOLERANT... /**************************************************************************/ /* */ /* FUNCTION RELEASE */ /* */ /* _fx_fault_tolerant_read_directory_sector PORTABLE C */ /* 6.1 */ /* AUTHOR */ /* */ /* William E. Lamie, Microsoft Corporation */ /* */ /* DESCRIPTION */ /* */ /* This function handles directory sector read requests. During file or*/ /* directory operations with Fault Tolerant protection, intermediate */ /* operations are written to the fault tolerant log files. Therefore, */ /* sector read should search for fault tolerant log before the request */ /* can be passed to normal directory entry read routine. */ /* */ /* INPUT */ /* */ /* media_ptr Media control block pointer */ /* logical_sector Logical sector number */ /* buffer_ptr Pointer of receiving buffer */ /* sectors Number of sectors to read */ /* */ /* OUTPUT */ /* */ /* return status */ /* */ /* CALLS */ /* */ /* _fx_utility_16_unsigned_read Read a USHORT from memory */ /* _fx_utility_32_unsigned_read Read a ULONG from memory */ /* memcpy Memory Copy */ /* */ /* CALLED BY */ /* */ /* _fx_utility_logical_sector_read */ /* */ /* RELEASE HISTORY */ /* */ /* DATE NAME DESCRIPTION */ /* */ /* 05-19-2020 William E. Lamie Initial Version 6.0 */ /* 09-30-2020 William E. Lamie Modified comment(s), verified */ /* memcpy usage, */ /* resulting in version 6.1 */ /* */... /**************************************************************************/ UINT _fx_fault_tolerant_read_directory_sector(FX_MEDIA *media_ptr, ULONG64 logical_sector, VOID *buffer_ptr, ULONG64 sectors) { ULONG logs_remaining; ULONG copy_offset; ULONG copy_size; UCHAR *current_ptr; UCHAR *current_buffer_ptr; ULONG size; USHORT type; ULONG log_len; ULONG64 log_sector; FX_FAULT_TOLERANT_DIR_LOG *dir_log; /* Get fault tolerant data. */ logs_remaining = media_ptr -> fx_media_fault_tolerant_total_logs; /* Any redo logs? */ if (logs_remaining == 0) { /* No. Just return. */ return(FX_SUCCESS); }if (logs_remaining == 0) { ... } /* Get size of all logs. */ size = media_ptr -> fx_media_fault_tolerant_file_size - FX_FAULT_TOLERANT_LOG_CONTENT_OFFSET; /* Get the first log pointer. */ current_ptr = media_ptr -> fx_media_fault_tolerant_memory_buffer + FX_FAULT_TOLERANT_LOG_CONTENT_OFFSET + FX_FAULT_TOLERANT_LOG_CONTENT_HEADER_SIZE; /* Loop throught all FAT logs. */ while (logs_remaining) { /* Check log type. */ type = (USHORT)_fx_utility_16_unsigned_read(current_ptr); /* Get log length. */ log_len = _fx_utility_16_unsigned_read(current_ptr + 2); /* Validate the size value. */ if (log_len > size) { /* Log file is corrupted. Nothing can be done. Return.*/ return(FX_FILE_CORRUPT); }if (log_len > size) { ... } size -= log_len; /* Check log type. */ if (type == FX_FAULT_TOLERANT_DIR_LOG_TYPE) { /* Get the log pointer. */ dir_log = (FX_FAULT_TOLERANT_DIR_LOG *)current_ptr; /* Get the sector of log. */ log_sector = _fx_utility_64_unsigned_read((UCHAR *)&dir_log -> fx_fault_tolerant_dir_log_sector); /* Is this log sector in the range of sectors to read? */ if ((log_sector >= logical_sector) && (log_sector < logical_sector + sectors)) { /* Yes. Update the content in this sector. */ current_buffer_ptr = ((UCHAR *)buffer_ptr) + (log_sector - logical_sector) * media_ptr -> fx_media_bytes_per_sector; /* Set copy information. */ copy_offset = _fx_utility_32_unsigned_read((UCHAR *)&dir_log -> fx_fault_tolerant_dir_log_offset); copy_size = log_len - FX_FAULT_TOLERANT_DIR_LOG_ENTRY_SIZE; if ((copy_offset + copy_size) > media_ptr -> fx_media_bytes_per_sector) { return(FX_FILE_CORRUPT); }if ((copy_offset + copy_size) > media_ptr -> fx_media_bytes_per_sector) { ... } /* Copy data into destination sector. */ memcpy(current_buffer_ptr + copy_offset, /* Use case of memcpy is verified. */ current_ptr + FX_FAULT_TOLERANT_DIR_LOG_ENTRY_SIZE, copy_size); }if ((log_sector >= logical_sector) && (log_sector < logical_sector + sectors)) { ... } }if (type == FX_FAULT_TOLERANT_DIR_LOG_TYPE) { ... } /* Decrease the logs_remaining counter. */ logs_remaining--; /* Move to start position of next log entry. */ current_ptr += log_len; }while (logs_remaining) { ... } /* Return success. */ return(FX_SUCCESS); }_fx_fault_tolerant_read_directory_sector (FX_MEDIA *media_ptr, ULONG64 logical_sector, VOID *buffer_ptr, ULONG64 sectors) { ... } /* ... */ #endif /* FX_ENABLE_FAULT_TOLERANT */
Details
Show:
from
Types: Columns:
This file uses the notable symbols shown below. Click anywhere in the file to view more details.