GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fxe_media_check.c Lines: 6 6 100.0 %
Date: 2024-01-10 21:53:23 Branches: 10 10 100.0 %

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

2449
    if ((media_ptr == FX_NULL) || (scratch_memory_ptr == FX_NULL))
123
    {
124
5
        return(FX_PTR_ERROR);
125
    }
126
127
    /* Check for a valid caller.  */
128

2444
    FX_CALLER_CHECKING_CODE
129
130
    /* Call actual media check service.  */
131
2036
    status =  _fx_media_check(media_ptr, scratch_memory_ptr, scratch_memory_size, error_correction_option, errors_detected);
132
133
    /* Return status to the caller.  */
134
2036
    return(status);
135
}
136