GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: fx_media_space_available.c Lines: 7 7 100.0 %
Date: 2024-03-11 05:15:45 Branches: 4 4 100.0 %

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