1 |
|
|
/*************************************************************************** |
2 |
|
|
* Copyright (c) 2024 Microsoft Corporation |
3 |
|
|
* |
4 |
|
|
* This program and the accompanying materials are made available under the |
5 |
|
|
* terms of the MIT License which is available at |
6 |
|
|
* https://opensource.org/licenses/MIT. |
7 |
|
|
* |
8 |
|
|
* SPDX-License-Identifier: MIT |
9 |
|
|
**************************************************************************/ |
10 |
|
|
|
11 |
|
|
|
12 |
|
|
/**************************************************************************/ |
13 |
|
|
/**************************************************************************/ |
14 |
|
|
/** */ |
15 |
|
|
/** FileX Component */ |
16 |
|
|
/** */ |
17 |
|
|
/** Media */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
/**************************************************************************/ |
21 |
|
|
|
22 |
|
|
#define FX_SOURCE_CODE |
23 |
|
|
|
24 |
|
|
|
25 |
|
|
/* Include necessary system files. */ |
26 |
|
|
|
27 |
|
|
#include "fx_api.h" |
28 |
|
|
#include "fx_media.h" |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
FX_CALLER_CHECKING_EXTERNS |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
/**************************************************************************/ |
35 |
|
|
/* */ |
36 |
|
|
/* FUNCTION RELEASE */ |
37 |
|
|
/* */ |
38 |
|
|
/* _fxe_media_check PORTABLE C */ |
39 |
|
|
/* 6.1 */ |
40 |
|
|
/* AUTHOR */ |
41 |
|
|
/* */ |
42 |
|
|
/* William E. Lamie, Microsoft Corporation */ |
43 |
|
|
/* */ |
44 |
|
|
/* DESCRIPTION */ |
45 |
|
|
/* */ |
46 |
|
|
/* This function checks for errors in the media check call. */ |
47 |
|
|
/* */ |
48 |
|
|
/* INPUT */ |
49 |
|
|
/* */ |
50 |
|
|
/* media_ptr Pointer to a previously */ |
51 |
|
|
/* opened media */ |
52 |
|
|
/* scratch_memory_ptr Pointer to memory area for */ |
53 |
|
|
/* check disk to use (as */ |
54 |
|
|
/* mentioned above) */ |
55 |
|
|
/* scratch_memory_size Size of the scratch memory */ |
56 |
|
|
/* error_correction_option Specifies which - if any - */ |
57 |
|
|
/* errors are corrected by */ |
58 |
|
|
/* the check disk function. */ |
59 |
|
|
/* Setting the following bit */ |
60 |
|
|
/* causes that error to be */ |
61 |
|
|
/* corrected: */ |
62 |
|
|
/* */ |
63 |
|
|
/* 0x01 -> Fix FAT Chain Errors*/ |
64 |
|
|
/* 0x02 -> Fix Directory Entry */ |
65 |
|
|
/* Errors */ |
66 |
|
|
/* 0x04 -> Fix Lost Clusters */ |
67 |
|
|
/* */ |
68 |
|
|
/* errors_detected Specifies the destination */ |
69 |
|
|
/* ULONG to place the error */ |
70 |
|
|
/* report from check disk. */ |
71 |
|
|
/* This has a similar bit map */ |
72 |
|
|
/* as before: */ |
73 |
|
|
/* */ |
74 |
|
|
/* 0x01 -> FAT Chain Error(s) */ |
75 |
|
|
/* 0x02 -> Directory Entry */ |
76 |
|
|
/* Error(s) */ |
77 |
|
|
/* 0x04 -> Lost Cluster(s) */ |
78 |
|
|
/* */ |
79 |
|
|
/* OUTPUT */ |
80 |
|
|
/* */ |
81 |
|
|
/* FX_SUCCESS Check disk performed its */ |
82 |
|
|
/* operation successfully. */ |
83 |
|
|
/* This does not mean that */ |
84 |
|
|
/* there were no errors. The */ |
85 |
|
|
/* errors_detected variable */ |
86 |
|
|
/* needs to be examined. */ |
87 |
|
|
/* FX_MEDIA_NOT_OPEN The media was not open. */ |
88 |
|
|
/* FX_NOT_ENOUGH_MEMORY The scratch memory was not */ |
89 |
|
|
/* large enough or the nesting */ |
90 |
|
|
/* depth was greater than the */ |
91 |
|
|
/* maximum specified. */ |
92 |
|
|
/* FX_IO_ERROR I/O Error reading/writing to */ |
93 |
|
|
/* the media. */ |
94 |
|
|
/* FX_ERROR_NOT_FIXED Fundamental problem with */ |
95 |
|
|
/* media that couldn't be fixed*/ |
96 |
|
|
/* */ |
97 |
|
|
/* CALLS */ |
98 |
|
|
/* */ |
99 |
|
|
/* _fx_media_check Actual media check service */ |
100 |
|
|
/* */ |
101 |
|
|
/* CALLED BY */ |
102 |
|
|
/* */ |
103 |
|
|
/* Application Code */ |
104 |
|
|
/* */ |
105 |
|
|
/* RELEASE HISTORY */ |
106 |
|
|
/* */ |
107 |
|
|
/* DATE NAME DESCRIPTION */ |
108 |
|
|
/* */ |
109 |
|
|
/* 05-19-2020 William E. Lamie Initial Version 6.0 */ |
110 |
|
|
/* 09-30-2020 William E. Lamie Modified comment(s), */ |
111 |
|
|
/* resulting in version 6.1 */ |
112 |
|
|
/* */ |
113 |
|
|
/**************************************************************************/ |
114 |
|
2449 |
UINT _fxe_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected) |
115 |
|
|
{ |
116 |
|
|
|
117 |
|
|
UINT status; |
118 |
|
|
|
119 |
|
|
|
120 |
|
|
/* Check for a NULL media or scratch pointer. */ |
121 |
✓✓✓✓
|
2449 |
if ((media_ptr == FX_NULL) || (scratch_memory_ptr == FX_NULL)) |
122 |
|
|
{ |
123 |
|
5 |
return(FX_PTR_ERROR); |
124 |
|
|
} |
125 |
|
|
|
126 |
|
|
/* Check for a valid caller. */ |
127 |
✓✓✓✓ ✓✓ |
2444 |
FX_CALLER_CHECKING_CODE |
128 |
|
|
|
129 |
|
|
/* Call actual media check service. */ |
130 |
|
2036 |
status = _fx_media_check(media_ptr, scratch_memory_ptr, scratch_memory_size, error_correction_option, errors_detected); |
131 |
|
|
|
132 |
|
|
/* Return status to the caller. */ |
133 |
|
2036 |
return(status); |
134 |
|
|
} |
135 |
|
|
|