fx_media_space_available.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_system.h" | ||
| 30 | #include "fx_media.h" | ||
| 31 | |||
| 32 | |||
| 33 | /**************************************************************************/ | ||
| 34 | /* */ | ||
| 35 | /* FUNCTION RELEASE */ | ||
| 36 | /* */ | ||
| 37 | /* _fx_media_space_available PORTABLE C */ | ||
| 38 | /* 6.1 */ | ||
| 39 | /* AUTHOR */ | ||
| 40 | /* */ | ||
| 41 | /* William E. Lamie, Microsoft Corporation */ | ||
| 42 | /* */ | ||
| 43 | /* DESCRIPTION */ | ||
| 44 | /* */ | ||
| 45 | /* This function returns the number of bytes available in the */ | ||
| 46 | /* specified media. */ | ||
| 47 | /* */ | ||
| 48 | /* INPUT */ | ||
| 49 | /* */ | ||
| 50 | /* media_ptr Media control block pointer */ | ||
| 51 | /* available_bytes_ptr Pointer to available bytes */ | ||
| 52 | /* destination */ | ||
| 53 | /* */ | ||
| 54 | /* OUTPUT */ | ||
| 55 | /* */ | ||
| 56 | /* return status */ | ||
| 57 | /* */ | ||
| 58 | /* CALLS */ | ||
| 59 | /* */ | ||
| 60 | /* None */ | ||
| 61 | /* */ | ||
| 62 | /* _fx_media_extended_space_available Actual space available service*/ | ||
| 63 | /* */ | ||
| 64 | /* CALLED BY */ | ||
| 65 | /* */ | ||
| 66 | /* Application Code */ | ||
| 67 | /* */ | ||
| 68 | /**************************************************************************/ | ||
| 69 | 13184 | UINT _fx_media_space_available(FX_MEDIA *media_ptr, ULONG *available_bytes_ptr) | |
| 70 | { | ||
| 71 | |||
| 72 | UINT status; | ||
| 73 | ULONG64 available_bytes; | ||
| 74 | |||
| 75 | /* Call actual media space available service. */ | ||
| 76 | 13184 | status = _fx_media_extended_space_available(media_ptr, &available_bytes); | |
| 77 | |||
| 78 | /* Check status. */ | ||
| 79 |
2/2✓ Branch 3 → 4 taken 12494 times.
✓ Branch 3 → 7 taken 690 times.
|
13184 | if (status == FX_SUCCESS) |
| 80 | { | ||
| 81 | |||
| 82 | /* Determine if more than 4GB available. */ | ||
| 83 |
2/2✓ Branch 4 → 5 taken 9 times.
✓ Branch 4 → 6 taken 12485 times.
|
12494 | if (available_bytes > 0x00000000FFFFFFFF) |
| 84 | { | ||
| 85 | |||
| 86 | /* Yes, we must have more than 4GB available... report the maximum we can fit | ||
| 87 | in 32bits, which is 4GB. */ | ||
| 88 | 9 | *available_bytes_ptr = 0xFFFFFFFF; | |
| 89 | } | ||
| 90 | else | ||
| 91 | { | ||
| 92 | 12485 | *available_bytes_ptr = (ULONG)(available_bytes); | |
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | /* Return status to the caller. */ | ||
| 97 | 13184 | return(status); | |
| 98 | } | ||
| 99 | |||
| 100 |