52 if (EFI_ERROR (Status)) {
77 UINTN SingleFileInfoSize;
79 UINT64 DirStreamCookie;
80 UINT64 CacheEndsAtCookie;
90 VirtioFs = VirtioFsFile->OwnerFs;
92 if (EFI_ERROR (Status)) {
99 if (DirentBufSize == 0) {
100 return EFI_UNSUPPORTED;
103 DirentBufSize *= VIRTIO_FS_FILE_MAX_FILE_INFO;
105 if (DirentBuf ==
NULL) {
106 return EFI_OUT_OF_RESOURCES;
119 ((
UINTN)FilesysAttr.Namelen + 1) *
sizeof (CHAR16));
121 VIRTIO_FS_FILE_MAX_FILE_INFO * SingleFileInfoSize
123 if (FileInfoArray ==
NULL) {
124 Status = EFI_OUT_OF_RESOURCES;
131 DirStreamCookie = VirtioFsFile->FilePosition;
132 CacheEndsAtCookie = VirtioFsFile->FilePosition;
144 Remaining = DirentBufSize;
147 VirtioFsFile->NodeId,
148 VirtioFsFile->FuseHandle,
154 if (EFI_ERROR (Status)) {
155 goto FreeFileInfoArray;
158 if (Remaining == 0) {
179 if (DirentSize == 0) {
187 Status = EFI_PROTOCOL_ERROR;
188 goto FreeFileInfoArray;
191 if (DirentSize > Remaining) {
197 Status = EFI_PROTOCOL_ERROR;
198 goto FreeFileInfoArray;
201 if (Dirent->Namelen > FilesysAttr.Namelen) {
208 Status = EFI_PROTOCOL_ERROR;
209 goto FreeFileInfoArray;
216 if (NumFileInfo < VIRTIO_FS_FILE_MAX_FILE_INFO) {
220 (NumFileInfo * SingleFileInfoSize));
222 if (!EFI_ERROR (Status)) {
232 CacheEndsAtCookie = Dirent->CookieForNextEntry;
247 if (Dirent->NodeResp.NodeId != 0) {
254 DirStreamCookie = Dirent->CookieForNextEntry;
255 Consumed += DirentSize;
256 Remaining -= DirentSize;
265 Status = EFI_PROTOCOL_ERROR;
266 goto FreeFileInfoArray;
273 }
while (NumFileInfo < VIRTIO_FS_FILE_MAX_FILE_INFO);
278 if (VirtioFsFile->FileInfoArray !=
NULL) {
279 FreePool (VirtioFsFile->FileInfoArray);
282 VirtioFsFile->FileInfoArray = FileInfoArray;
283 VirtioFsFile->SingleFileInfoSize = SingleFileInfoSize;
284 VirtioFsFile->NumFileInfo = NumFileInfo;
285 VirtioFsFile->NextFileInfo = 0;
286 VirtioFsFile->FilePosition = CacheEndsAtCookie;
312 UINTN CallerAllocated;
318 if (VirtioFsFile->NextFileInfo == VirtioFsFile->NumFileInfo) {
322 if (EFI_ERROR (Status)) {
323 return (Status == EFI_BUFFER_TOO_SMALL) ? EFI_DEVICE_ERROR : Status;
326 if (VirtioFsFile->NumFileInfo == 0) {
333 (VirtioFsFile->NextFileInfo *
334 VirtioFsFile->SingleFileInfoSize));
351 CallerAllocated = *BufferSize;
353 if (CallerAllocated < *BufferSize) {
354 return EFI_BUFFER_TOO_SMALL;
361 VirtioFsFile->NextFileInfo++;
382 VirtioFs = VirtioFsFile->OwnerFs;
387 if (EFI_ERROR (Status) || (VirtioFsFile->FilePosition > FuseAttr.Size)) {
388 return EFI_DEVICE_ERROR;
400 ReadSize = (UINT32)
MIN ((
UINTN)MAX_UINT32, Left);
403 VirtioFsFile->NodeId,
404 VirtioFsFile->FuseHandle,
406 VirtioFsFile->FilePosition + Transferred,
408 (UINT8 *)Buffer + Transferred
410 if (EFI_ERROR (Status) || (ReadSize == 0)) {
414 Transferred += ReadSize;
418 *BufferSize = Transferred;
419 VirtioFsFile->FilePosition += Transferred;
431VirtioFsSimpleFileRead (
440 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
442 if (VirtioFsFile->IsDirectory) {
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS VirtioFsFuseForget(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId)
EFI_STATUS VirtioFsFuseGetAttr(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
EFI_STATUS VirtioFsFuseReadFileOrDir(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 FuseHandle, IN BOOLEAN IsDir, IN UINT64 Offset, IN OUT UINT32 *Size, OUT VOID *Data)
EFI_STATUS VirtioFsFuseStatFs(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, OUT VIRTIO_FS_FUSE_STATFS_RESPONSE *FilesysAttr)
#define OFFSET_OF(TYPE, Field)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
STATIC EFI_STATUS PopulateFileInfo(IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *Dirent, IN UINTN SingleFileInfoSize, OUT EFI_FILE_INFO *FileInfo)
STATIC EFI_STATUS RefillFileInfoCache(IN OUT VIRTIO_FS_FILE *VirtioFsFile)
STATIC EFI_STATUS ReadFileInfoCache(IN OUT VIRTIO_FS_FILE *VirtioFsFile, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
STATIC EFI_STATUS ReadRegularFile(IN OUT VIRTIO_FS_FILE *VirtioFsFile, IN OUT UINTN *BufferSize, OUT VOID *Buffer)
#define VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE(Namelen)
EFI_STATUS VirtioFsFuseDirentPlusToEfiFileInfo(IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent, IN OUT EFI_FILE_INFO *FileInfo)
EFI_STATUS VirtioFsFuseAttrToEfiFileInfo(IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr, OUT EFI_FILE_INFO *FileInfo)