TianoCore EDK2 master
Loading...
Searching...
No Matches
SimpleFsSetPosition.c
Go to the documentation of this file.
1
10#include <Library/MemoryAllocationLib.h> // FreePool()
11
12#include "VirtioFsDxe.h"
13
15EFIAPI
16VirtioFsSimpleFileSetPosition (
18 IN UINT64 Position
19 )
20{
21 VIRTIO_FS_FILE *VirtioFsFile;
22 VIRTIO_FS *VirtioFs;
23 EFI_STATUS Status;
25
26 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
27
28 //
29 // Directories can only be rewound, per spec.
30 //
31 if (VirtioFsFile->IsDirectory) {
32 if (Position != 0) {
33 return EFI_UNSUPPORTED;
34 }
35
36 VirtioFsFile->FilePosition = 0;
37 if (VirtioFsFile->FileInfoArray != NULL) {
38 FreePool (VirtioFsFile->FileInfoArray);
39 VirtioFsFile->FileInfoArray = NULL;
40 }
41
42 VirtioFsFile->SingleFileInfoSize = 0;
43 VirtioFsFile->NumFileInfo = 0;
44 VirtioFsFile->NextFileInfo = 0;
45 return EFI_SUCCESS;
46 }
47
48 //
49 // Regular file.
50 //
51 if (Position < MAX_UINT64) {
52 //
53 // Caller is requesting absolute file position.
54 //
55 VirtioFsFile->FilePosition = Position;
56 return EFI_SUCCESS;
57 }
58
59 //
60 // Caller is requesting a seek to EOF.
61 //
62 VirtioFs = VirtioFsFile->OwnerFs;
63 Status = VirtioFsFuseGetAttr (VirtioFs, VirtioFsFile->NodeId, &FuseAttr);
64 if (EFI_ERROR (Status)) {
65 return Status;
66 }
67
68 VirtioFsFile->FilePosition = FuseAttr.Size;
69 return EFI_SUCCESS;
70}
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS VirtioFsFuseGetAttr(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
Definition: FuseGetAttr.c:39
#define NULL
Definition: Base.h:319
#define IN
Definition: Base.h:279
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112