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 |
|
|
/** File */ |
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_file.h" |
30 |
|
|
|
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _fx_file_best_effort_allocate PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* William E. Lamie, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function attempts to allocate the number of consecutive */ |
45 |
|
|
/* clusters required to satisfy the user's request. If there are not */ |
46 |
|
|
/* enough clusters, the largest set of clusters are allocated and */ |
47 |
|
|
/* linked to the file. If there are no free clusters, an error */ |
48 |
|
|
/* code is returned to the caller. */ |
49 |
|
|
/* */ |
50 |
|
|
/* INPUT */ |
51 |
|
|
/* */ |
52 |
|
|
/* file_ptr File control block pointer */ |
53 |
|
|
/* size Number of bytes to allocate */ |
54 |
|
|
/* actual_size_allocated Number of bytes allocated */ |
55 |
|
|
/* */ |
56 |
|
|
/* OUTPUT */ |
57 |
|
|
/* */ |
58 |
|
|
/* return status */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLS */ |
61 |
|
|
/* */ |
62 |
|
|
/* _fx_file_extended_best_effort_allocate */ |
63 |
|
|
/* Allocate the largest set of */ |
64 |
|
|
/* clusters */ |
65 |
|
|
/* */ |
66 |
|
|
/* CALLED BY */ |
67 |
|
|
/* */ |
68 |
|
|
/* Application Code */ |
69 |
|
|
/* */ |
70 |
|
|
/* RELEASE HISTORY */ |
71 |
|
|
/* */ |
72 |
|
|
/* DATE NAME DESCRIPTION */ |
73 |
|
|
/* */ |
74 |
|
|
/* 05-19-2020 William E. Lamie Initial Version 6.0 */ |
75 |
|
|
/* 09-30-2020 William E. Lamie Modified comment(s), */ |
76 |
|
|
/* resulting in version 6.1 */ |
77 |
|
|
/* */ |
78 |
|
|
/**************************************************************************/ |
79 |
|
2 |
UINT _fx_file_best_effort_allocate(FX_FILE *file_ptr, ULONG size, ULONG *actual_size_allocated) |
80 |
|
|
{ |
81 |
|
|
|
82 |
|
|
UINT status; |
83 |
|
|
ULONG64 temp_actual_size_allocated; |
84 |
|
|
|
85 |
|
|
/* Call actual best effort file allocate service. */ |
86 |
|
2 |
status = _fx_file_extended_best_effort_allocate(file_ptr, (ULONG64)size, &temp_actual_size_allocated); |
87 |
|
|
|
88 |
|
|
/* Check status. */ |
89 |
✓✓ |
2 |
if (status == FX_SUCCESS) |
90 |
|
|
{ |
91 |
|
1 |
*actual_size_allocated = (ULONG)temp_actual_size_allocated; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
/* Return status to the caller. */ |
95 |
|
2 |
return(status); |
96 |
|
|
} |
97 |
|
|
|