-
Notifications
You must be signed in to change notification settings - Fork 2
/
Flush.c
122 lines (95 loc) · 2.22 KB
/
Flush.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/*++
Copyright (c) 2005 - 2013, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2016, The EFIDroid Project. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Module Name:
flush.c
Abstract:
Routines that check references and flush OFiles
Revision History
--*/
#include "LKL.h"
EFI_STATUS
EFIAPI
LKLFlush (
IN EFI_FILE_PROTOCOL *FHand
)
{
LKL_IFILE *IFile;
LKL_VOLUME *Volume;
EFI_STATUS Status;
INTN RC;
IFile = IFILE_FROM_FHAND (FHand);
Volume = IFile->Volume;
(VOID)(Volume);
RC = lkl_sys_fsync(IFile->FD);
Status = LKLError2EfiError(RC);
return Status;
}
EFI_STATUS
EFIAPI
LKLFlushEx (
IN EFI_FILE_PROTOCOL *FHand,
IN EFI_FILE_IO_TOKEN *Token
)
{
DEBUG((EFI_D_ERROR, "%a:%u\n", __func__, __LINE__));
return EFI_DEVICE_ERROR;
}
EFI_STATUS
EFIAPI
LKLClose (
IN EFI_FILE_PROTOCOL *FHand
)
{
LKL_IFILE *IFile;
LKL_VOLUME *Volume;
IFile = IFILE_FROM_FHAND (FHand);
Volume = IFile->Volume;
(VOID)(Volume);
//
// Close the file instance handle
//
LKLIFileClose (IFile);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
LKLDelete (
IN EFI_FILE_PROTOCOL *FHand
)
{
INTN RC;
EFI_STATUS Status;
LKL_IFILE *IFile;
LKL_VOLUME *Volume;
IFile = IFILE_FROM_FHAND (FHand);
Volume = IFile->Volume;
(VOID)(Volume);
Status = EFI_WARN_DELETE_FAILURE;
UINTN FilePathSize = AsciiStrLen(Volume->LKLMountPoint) + 1 + AsciiStrLen(IFile->FilePath) + 1;
CHAR8* FilePath = AllocatePool(FilePathSize);
if (FilePath) {
AsciiSPrint(FilePath, FilePathSize, "%a/%a", Volume->LKLMountPoint, IFile->FilePath);
}
//
// Close the file instance handle
//
LKLIFileClose (IFile);
if (FilePath) {
//
// Close the file instance handle
//
RC = lkl_sys_unlink(FilePath);
if (RC==0) {
Status = EFI_SUCCESS;
}
FreePool (FilePath);
}
return Status;
}