GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_media_space_available.c Lines: 7 7 100.0 %
Date: 2026-03-06 18:49:02 Branches: 4 4 100.0 %

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
162
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
162
    status = _fx_media_extended_space_available(media_ptr, &available_bytes);
77
78
    /* Check status.  */
79
162
    if (status == FX_SUCCESS)
80
    {
81
82
        /* Determine if more than 4GB available.  */
83
26
        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
1
            *available_bytes_ptr = 0xFFFFFFFF;
89
        }
90
        else
91
        {
92
25
            *available_bytes_ptr = (ULONG)(available_bytes);
93
        }
94
    }
95
96
    /* Return status to the caller.  */
97
162
    return(status);
98
}
99