fxe_media_check.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 | /** 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 | /**************************************************************************/ | ||
| 107 | 18434 | UINT _fxe_media_check(FX_MEDIA *media_ptr, UCHAR *scratch_memory_ptr, ULONG scratch_memory_size, ULONG error_correction_option, ULONG *errors_detected) | |
| 108 | { | ||
| 109 | |||
| 110 | UINT status; | ||
| 111 | |||
| 112 | |||
| 113 | /* Check for a NULL media or scratch pointer. */ | ||
| 114 |
4/4✓ Branch 2 → 3 taken 18410 times.
✓ Branch 2 → 4 taken 24 times.
✓ Branch 3 → 4 taken 16 times.
✓ Branch 3 → 5 taken 18394 times.
|
18434 | if ((media_ptr == FX_NULL) || (scratch_memory_ptr == FX_NULL)) |
| 115 | { | ||
| 116 | 40 | return(FX_PTR_ERROR); | |
| 117 | } | ||
| 118 | |||
| 119 | /* Check for a valid caller. */ | ||
| 120 |
6/6✓ Branch 5 → 6 taken 9542 times.
✓ Branch 5 → 8 taken 690 times.
✓ Branch 6 → 7 taken 8852 times.
✓ Branch 6 → 8 taken 690 times.
✓ Branch 7 → 8 taken 690 times.
✓ Branch 7 → 9 taken 8162 times.
|
10232 | FX_CALLER_CHECKING_CODE |
| 121 | |||
| 122 | /* Call actual media check service. */ | ||
| 123 | 16324 | status = _fx_media_check(media_ptr, scratch_memory_ptr, scratch_memory_size, error_correction_option, errors_detected); | |
| 124 | |||
| 125 | /* Return status to the caller. */ | ||
| 126 | 16324 | return(status); | |
| 127 | } | ||
| 128 | |||
| 129 |