39 for (Idx = 0; Idx < VIRTIO_FS_TAG_BYTES; Idx++) {
40 Status = Virtio->ReadDevice (
43 sizeof Config->Tag[Idx],
44 sizeof Config->Tag[Idx],
47 if (EFI_ERROR (Status)) {
52 Status = Virtio->ReadDevice (
55 sizeof Config->NumReqQueues,
56 sizeof Config->NumReqQueues,
98 Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
99 if (EFI_ERROR (Status)) {
106 NextDevStat |= VSTAT_ACK;
107 Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
108 if (EFI_ERROR (Status)) {
115 NextDevStat |= VSTAT_DRIVER;
116 Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
117 if (EFI_ERROR (Status)) {
124 Status = VirtioFs->Virtio->GetDeviceFeatures (VirtioFs->Virtio, &Features);
125 if (EFI_ERROR (Status)) {
129 if ((Features & VIRTIO_F_VERSION_1) == 0) {
130 Status = EFI_UNSUPPORTED;
139 Features &= VIRTIO_F_VERSION_1 | VIRTIO_F_IOMMU_PLATFORM;
148 if (EFI_ERROR (Status)) {
157 if (EFI_ERROR (Status)) {
167 for (Idx = 0; Idx < VIRTIO_FS_TAG_BYTES && Config.Tag[Idx] !=
'\0'; Idx++) {
168 if ((Config.Tag[Idx] < 0x20) || (Config.Tag[Idx] > 0x7E)) {
169 Status = EFI_UNSUPPORTED;
173 VirtioFs->Label[Idx] = Config.Tag[Idx];
176 VirtioFs->Label[Idx] = L
'\0';
181 if (Config.NumReqQueues < 1) {
182 Status = EFI_UNSUPPORTED;
191 Status = VirtioFs->Virtio->SetQueueSel (
193 VIRTIO_FS_REQUEST_QUEUE
195 if (EFI_ERROR (Status)) {
199 Status = VirtioFs->Virtio->GetQueueNumMax (
203 if (EFI_ERROR (Status)) {
207 if (VirtioFs->QueueSize < 2) {
208 Status = EFI_UNSUPPORTED;
220 if (EFI_ERROR (Status)) {
230 if (EFI_ERROR (Status)) {
234 Status = VirtioFs->Virtio->SetQueueAddress (
239 if (EFI_ERROR (Status)) {
246 NextDevStat |= VSTAT_DRIVER_OK;
247 Status = VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
248 if (EFI_ERROR (Status)) {
255 VirtioFs->Virtio->UnmapSharedBuffer (VirtioFs->Virtio, VirtioFs->RingMap);
268 NextDevStat |= VSTAT_FAILED;
269 VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, NextDevStat);
292 VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, 0);
293 VirtioFs->Virtio->UnmapSharedBuffer (VirtioFs->Virtio, VirtioFs->RingMap);
314 IN VOID *VirtioFsAsVoid
319 VirtioFs = VirtioFsAsVoid;
322 "%a: VirtioFs=0x%p Label=\"%s\"\n",
327 VirtioFs->Virtio->SetDeviceStatus (VirtioFs->Virtio, 0);
405 UINT16 DescriptorsNeeded;
408 if (RequestSgList ==
NULL) {
409 return EFI_INVALID_PARAMETER;
412 SgListParam[0] = RequestSgList;
413 SgListParam[1] = ResponseSgList;
415 DescriptorsNeeded = 0;
416 for (ListId = 0; ListId <
ARRAY_SIZE (SgListParam); ListId++) {
418 UINT32 SgListTotalSize;
421 SgList = SgListParam[ListId];
422 if (SgList ==
NULL) {
429 if ((SgList->IoVec ==
NULL) || (SgList->NumVec == 0)) {
430 return EFI_INVALID_PARAMETER;
438 if ((SgList->NumVec > (
UINTN)(MAX_UINT16 - DescriptorsNeeded)) ||
439 (DescriptorsNeeded + SgList->NumVec > VirtioFs->QueueSize))
441 return EFI_UNSUPPORTED;
444 DescriptorsNeeded += (UINT16)SgList->NumVec;
447 for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
450 IoVec = &SgList->IoVec[IoVecIdx];
454 if ((IoVec->Buffer ==
NULL) || (IoVec->Size == 0)) {
455 return EFI_INVALID_PARAMETER;
462 if (IoVec->Size > MAX_UINT32 - SgListTotalSize) {
463 return EFI_UNSUPPORTED;
466 SgListTotalSize += (UINT32)IoVec->Size;
472 IoVec->Mapped =
FALSE;
473 IoVec->MappedAddress = 0;
474 IoVec->Mapping =
NULL;
475 IoVec->Transferred = 0;
482 SgList->TotalSize = SgListTotalSize;
545 VIRTIO_MAP_OPERATION SgListVirtioMapOp[
ARRAY_SIZE (SgListParam)];
546 UINT16 SgListDescriptorFlag[
ARRAY_SIZE (SgListParam)];
553 UINT32 TotalBytesWrittenByDevice;
554 UINT32 BytesPermittedForWrite;
556 SgListParam[0] = RequestSgList;
557 SgListVirtioMapOp[0] = VirtioOperationBusMasterRead;
558 SgListDescriptorFlag[0] = 0;
560 SgListParam[1] = ResponseSgList;
561 SgListVirtioMapOp[1] = VirtioOperationBusMasterWrite;
562 SgListDescriptorFlag[1] = VRING_DESC_F_WRITE;
567 for (ListId = 0; ListId <
ARRAY_SIZE (SgListParam); ListId++) {
568 SgList = SgListParam[ListId];
569 if (SgList ==
NULL) {
573 for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
574 IoVec = &SgList->IoVec[IoVecIdx];
580 SgListVirtioMapOp[ListId],
583 &IoVec->MappedAddress,
586 if (EFI_ERROR (Status)) {
590 IoVec->Mapped =
TRUE;
598 for (ListId = 0; ListId <
ARRAY_SIZE (SgListParam); ListId++) {
599 SgList = SgListParam[ListId];
600 if (SgList ==
NULL) {
604 for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
607 IoVec = &SgList->IoVec[IoVecIdx];
611 NextFlag = VRING_DESC_F_NEXT;
612 if ((ListId ==
ARRAY_SIZE (SgListParam) - 1) &&
613 (IoVecIdx == SgList->NumVec - 1))
620 IoVec->MappedAddress,
622 SgListDescriptorFlag[ListId] | NextFlag,
633 VIRTIO_FS_REQUEST_QUEUE,
636 &TotalBytesWrittenByDevice
638 if (EFI_ERROR (Status)) {
646 if (ResponseSgList ==
NULL) {
647 BytesPermittedForWrite = 0;
649 BytesPermittedForWrite = ResponseSgList->TotalSize;
652 if (TotalBytesWrittenByDevice > BytesPermittedForWrite) {
653 Status = EFI_DEVICE_ERROR;
660 for (ListId = 0; ListId <
ARRAY_SIZE (SgListParam); ListId++) {
661 SgList = SgListParam[ListId];
662 if (SgList ==
NULL) {
666 for (IoVecIdx = 0; IoVecIdx < SgList->NumVec; IoVecIdx++) {
667 IoVec = &SgList->IoVec[IoVecIdx];
668 if (SgListVirtioMapOp[ListId] == VirtioOperationBusMasterRead) {
673 IoVec->Transferred = IoVec->Size;
682 IoVec->Transferred =
MIN (
683 (
UINTN)TotalBytesWrittenByDevice,
686 TotalBytesWrittenByDevice -= (UINT32)IoVec->Transferred;
694 ASSERT (TotalBytesWrittenByDevice == 0);
708 SgList = SgListParam[ListId];
709 if (SgList ==
NULL) {
713 IoVecIdx = SgList->NumVec;
714 while (IoVecIdx > 0) {
718 IoVec = &SgList->IoVec[IoVecIdx];
722 if (!IoVec->Mapped) {
726 UnmapStatus = VirtioFs->Virtio->UnmapSharedBuffer (
735 IoVec->Mapped =
FALSE;
736 IoVec->MappedAddress = 0;
737 IoVec->Mapping =
NULL;
746 if (!EFI_ERROR (Status) && EFI_ERROR (UnmapStatus)) {
747 Status = UnmapStatus;
793 IN UINT32 RequestSize,
794 IN VIRTIO_FS_FUSE_OPCODE Opcode,
798 if (RequestSize <
sizeof *Request) {
799 return EFI_INVALID_PARAMETER;
802 if (VirtioFs->RequestId == MAX_UINT64) {
803 return EFI_OUT_OF_RESOURCES;
806 Request->Len = RequestSize;
807 Request->Opcode = Opcode;
808 Request->Unique = VirtioFs->RequestId++;
809 Request->NodeId = NodeId;
813 Request->Padding = 0;
879 UINTN NumFixedSizeVec;
881 UINT32 TotalTransferred;
887 ASSERT (ResponseSgList->NumVec > 0);
889 if (TailBufferFill ==
NULL) {
893 NumFixedSizeVec = ResponseSgList->NumVec;
900 if (ResponseSgList->NumVec == 1) {
901 return EFI_INVALID_PARAMETER;
904 NumFixedSizeVec = ResponseSgList->NumVec - 1;
911 if (ResponseSgList->IoVec[0].Size !=
sizeof *CommonResp) {
912 return EFI_INVALID_PARAMETER;
915 if (ResponseSgList->IoVec[0].Transferred != ResponseSgList->IoVec[0].Size) {
916 return EFI_PROTOCOL_ERROR;
923 CommonResp = ResponseSgList->IoVec[0].Buffer;
924 TotalTransferred = 0;
925 for (Idx = 0; Idx < ResponseSgList->NumVec; Idx++) {
930 TotalTransferred += (UINT32)ResponseSgList->IoVec[Idx].Transferred;
933 if (CommonResp->Len != TotalTransferred) {
934 return EFI_PROTOCOL_ERROR;
940 if (CommonResp->Unique != RequestId) {
941 return EFI_PROTOCOL_ERROR;
948 if (CommonResp->Error != 0) {
949 return EFI_DEVICE_ERROR;
957 ASSERT (NumFixedSizeVec >= 1);
958 for (Idx = 1; Idx < NumFixedSizeVec; Idx++) {
959 if (ResponseSgList->IoVec[Idx].Transferred !=
960 ResponseSgList->IoVec[Idx].Size)
962 return EFI_PROTOCOL_ERROR;
969 if (TailBufferFill !=
NULL) {
970 *TailBufferFill = ResponseSgList->IoVec[NumFixedSizeVec].Transferred;
997 return EFI_SECURITY_VIOLATION;
1008 return EFI_NOT_FOUND;
1019 return EFI_NOT_READY;
1028 return EFI_DEVICE_ERROR;
1033 return EFI_BAD_BUFFER_SIZE;
1059 return EFI_UNSUPPORTED;
1070 return EFI_NO_MAPPING;
1087 return EFI_OUT_OF_RESOURCES;
1090 return EFI_ACCESS_DENIED;
1097 return EFI_ALREADY_STARTED;
1101 return EFI_INVALID_PARAMETER;
1105 return EFI_VOLUME_FULL;
1108 return EFI_WRITE_PROTECTED;
1132 return EFI_BUFFER_TOO_SMALL;
1137 return EFI_END_OF_FILE;
1153 return EFI_NO_MEDIA;
1156 return EFI_PROTOCOL_ERROR;
1163 return EFI_VOLUME_CORRUPTED;
1167 return EFI_NOT_STARTED;
1173 return EFI_DEVICE_ERROR;
1211 ASSERT (*Position >= 1);
1212 ASSERT (Buffer[*Position - 1] ==
'/');
1213 if (*Position == 1) {
1245 ASSERT (*Position < Size);
1246 Buffer[(*Position)++] = Char8;
1270 ASSERT (*Position >= 2);
1271 ASSERT (Buffer[*Position - 1] ==
'.');
1272 ASSERT (Buffer[*Position - 2] ==
'/');
1311 OUT BOOLEAN *RootEscape
1315 ASSERT (*Position >= 3);
1316 ASSERT (Buffer[*Position - 1] ==
'.');
1317 ASSERT (Buffer[*Position - 2] ==
'.');
1318 ASSERT (Buffer[*Position - 3] ==
'/');
1321 if (*Position == 1) {
1337 ASSERT (*Position > 0);
1339 }
while (Buffer[*Position] !=
'/');
1406 IN CHAR16 *RhsPath16,
1407 OUT CHAR8 **ResultPath8,
1408 OUT BOOLEAN *RootEscape
1415 UINTN SizeToSanitize;
1416 CHAR8 *BufferToSanitize;
1417 CHAR8 *SanitizedBuffer;
1419 UINTN SanitizedPosition;
1424 RhsLen =
StrLen (RhsPath16);
1426 return EFI_INVALID_PARAMETER;
1432 if (RhsLen > VIRTIO_FS_MAX_PATHNAME_LENGTH) {
1433 return EFI_INVALID_PARAMETER;
1444 if (RhsPath8 ==
NULL) {
1445 return EFI_OUT_OF_RESOURCES;
1448 for (Idx = 0; RhsPath16[Idx] != L
'\0'; Idx++) {
1449 if ((RhsPath16[Idx] < 0x20) || (RhsPath16[Idx] > 0x7E) ||
1450 (RhsPath16[Idx] == L
'/'))
1452 Status = EFI_UNSUPPORTED;
1456 RhsPath8[Idx] = (CHAR8)((RhsPath16[Idx] == L
'\\') ? L
'/' : RhsPath16[Idx]);
1459 RhsPath8[Idx++] =
'\0';
1470 if (RhsPath8[0] ==
'/') {
1475 SizeToSanitize = RhsLen + 1;
1476 BufferToSanitize = RhsPath8;
1485 SizeToSanitize = LhsLen + 1 + RhsLen + 1;
1487 if (BufferToSanitize ==
NULL) {
1488 Status = EFI_OUT_OF_RESOURCES;
1492 CopyMem (BufferToSanitize, LhsPath8, LhsLen);
1493 BufferToSanitize[LhsLen] =
'/';
1494 CopyMem (BufferToSanitize + LhsLen + 1, RhsPath8, RhsLen + 1);
1501 if (SanitizedBuffer ==
NULL) {
1502 Status = EFI_OUT_OF_RESOURCES;
1503 goto FreeBufferToSanitize;
1510 *RootEscape =
FALSE;
1513 SanitizedPosition = 0;
1517 ASSERT (Idx < SizeToSanitize);
1518 Chr8 = BufferToSanitize[Idx++];
1522 ASSERT (Chr8 ==
'/');
1523 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1524 State = ParserSlash;
1531 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1540 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1544 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1545 State = ParserNormal;
1556 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1561 State = ParserSlash;
1564 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1565 State = ParserDotDot;
1568 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1569 State = ParserNormal;
1580 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1585 State = ParserSlash;
1592 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1593 State = ParserNormal;
1602 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1606 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1607 State = ParserSlash;
1617 ParserCopy (SanitizedBuffer, &SanitizedPosition, SizeToSanitize, Chr8);
1627 }
while (State != ParserEnd);
1632 ASSERT (SanitizedPosition >= 2);
1633 if (SanitizedPosition - 1 > VIRTIO_FS_MAX_PATHNAME_LENGTH) {
1634 Status = EFI_OUT_OF_RESOURCES;
1635 goto FreeSanitizedBuffer;
1638 *ResultPath8 = SanitizedBuffer;
1639 SanitizedBuffer =
NULL;
1645 if (SanitizedBuffer !=
NULL) {
1649FreeBufferToSanitize:
1650 if (RhsPath8[0] !=
'/') {
1704 OUT UINT64 *DirNodeId,
1705 OUT CHAR8 **LastComponent
1708 UINT64 ParentDirNodeId;
1711 UINT64 NextDirNodeId;
1714 return EFI_INVALID_PARAMETER;
1717 ParentDirNodeId = VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID;
1728 if (NextSlash ==
NULL) {
1750 if (ParentDirNodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
1757 if (EFI_ERROR (Status)) {
1766 if (EFI_ERROR (Status)) {
1767 goto ForgetNextDirNodeId;
1771 Status = EFI_ACCESS_DENIED;
1772 goto ForgetNextDirNodeId;
1778 ParentDirNodeId = NextDirNodeId;
1787 *DirNodeId = ParentDirNodeId;
1788 *LastComponent = Slash + 1;
1825 OUT CHAR16 *Basename OPTIONAL,
1830 UINTN LastComponent;
1834 AllocSize = *BasenameSize;
1836 LastComponent = MAX_UINTN;
1837 for (Idx = 0; Path[Idx] !=
'\0'; Idx++) {
1838 if (Path[Idx] ==
'/') {
1839 LastComponent = Idx;
1844 ASSERT (LastComponent < MAX_UINTN);
1846 *BasenameSize = (PathSize - LastComponent) *
sizeof Basename[0];
1848 if (*BasenameSize > AllocSize) {
1849 return EFI_BUFFER_TOO_SMALL;
1852 for (Idx = LastComponent; Idx < PathSize; Idx++) {
1853 Basename[Idx - LastComponent] = Path[Idx];
1920 IN CHAR16 *RhsPath16,
1921 OUT CHAR8 **ResultPath8,
1922 OUT BOOLEAN *RootEscape
1931 UINTN LhsBasename16Size;
1933 UINTN LhsBasenameLen;
1934 UINTN DestSuffix16Size;
1935 CHAR16 *DestSuffix16;
1941 RhsLen =
StrLen (RhsPath16);
1943 return EFI_INVALID_PARAMETER;
1949 if (RhsLen > VIRTIO_FS_MAX_PATHNAME_LENGTH) {
1950 return EFI_INVALID_PARAMETER;
1956 LhsBasename16Size = 0;
1958 ASSERT (Status == EFI_BUFFER_TOO_SMALL);
1959 ASSERT (LhsBasename16Size >=
sizeof (CHAR16));
1960 ASSERT (LhsBasename16Size %
sizeof (CHAR16) == 0);
1961 LhsBasenameLen = LhsBasename16Size /
sizeof (CHAR16) - 1;
1962 if (LhsBasenameLen == 0) {
1966 return EFI_INVALID_PARAMETER;
1972 if (RhsPath16[RhsLen - 1] == L
'\\') {
1976 DestSuffix16Size = RhsLen *
sizeof (CHAR16) + LhsBasename16Size;
1978 if (DestSuffix16 ==
NULL) {
1979 return EFI_OUT_OF_RESOURCES;
1982 CopyMem (DestSuffix16, RhsPath16, RhsLen *
sizeof (CHAR16));
1985 DestSuffix16 + RhsLen,
1993 DestSuffix16Size = (RhsLen + 1) *
sizeof (CHAR16);
1995 if (DestSuffix16 ==
NULL) {
1996 return EFI_OUT_OF_RESOURCES;
2009 if (DestSuffix16[0] == L
'\\') {
2011 if (DestPrefix8 ==
NULL) {
2012 Status = EFI_OUT_OF_RESOURCES;
2013 goto FreeDestSuffix16;
2017 UINTN DestPrefixLen;
2023 ASSERT (LhsBasenameLen < LhsLen);
2024 DestPrefixLen = LhsLen - LhsBasenameLen;
2025 ASSERT (LhsPath8[DestPrefixLen - 1] ==
'/');
2029 if (DestPrefixLen > 1) {
2034 if (DestPrefix8 ==
NULL) {
2035 Status = EFI_OUT_OF_RESOURCES;
2036 goto FreeDestSuffix16;
2039 CopyMem (DestPrefix8, LhsPath8, DestPrefixLen);
2040 DestPrefix8[DestPrefixLen] =
'\0';
2095 UINT64 EpochTime[3];
2104 if (FuseAttr->Blocks >= BIT55) {
2105 return EFI_UNSUPPORTED;
2115 EpochTime[0] = FuseAttr->Mtime;
2116 EpochTime[1] = FuseAttr->Atime;
2117 EpochTime[2] = FuseAttr->Mtime;
2122 for (Idx = 0; Idx <
ARRAY_SIZE (EpochTime); Idx++) {
2126 if (EpochTime[Idx] > MAX_UINTN) {
2127 return EFI_UNSUPPORTED;
2139 ConvertedTime[Idx]->TimeZone = 0;
2140 ConvertedTime[Idx]->Daylight = 0;
2144 ConvertedTime[Idx]->Pad1 = 0;
2145 ConvertedTime[Idx]->Pad2 = 0;
2151 switch (FuseAttr->Mode & VIRTIO_FS_FUSE_MODE_TYPE_MASK) {
2152 case VIRTIO_FS_FUSE_MODE_TYPE_DIR:
2155 case VIRTIO_FS_FUSE_MODE_TYPE_REG:
2162 return EFI_UNSUPPORTED;
2169 if ((FuseAttr->Mode & (VIRTIO_FS_FUSE_MODE_PERM_WUSR |
2170 VIRTIO_FS_FUSE_MODE_PERM_WGRP |
2171 VIRTIO_FS_FUSE_MODE_PERM_WOTH)) == 0)
2179 if (((
FileInfo->
Attribute & EFI_FILE_DIRECTORY) == 0) && (FuseAttr->Nlink > 1)) {
2180 return EFI_UNSUPPORTED;
2230 if (DirentSize == 0) {
2231 return EFI_INVALID_PARAMETER;
2238 ((
UINTN)FuseDirent->Namelen + 1) *
sizeof (CHAR16));
2240 return EFI_BUFFER_TOO_SMALL;
2246 DirentName = (UINT8 *)(FuseDirent + 1);
2247 for (Idx = 0; Idx < FuseDirent->Namelen; Idx++) {
2250 NameByte = DirentName[Idx];
2251 if ((NameByte < 0x20) || (NameByte > 0x7E) ||
2252 (NameByte ==
'/') || (NameByte ==
'\\'))
2254 return EFI_UNSUPPORTED;
2293 OUT BOOLEAN *Update,
2297 BOOLEAN IsDirectory;
2299 IsDirectory = (BOOLEAN)((Info->Attribute & EFI_FILE_DIRECTORY) != 0);
2301 if (IsDirectory || (Info->FileSize == NewInfo->FileSize)) {
2307 *Size = NewInfo->FileSize;
2358 OUT BOOLEAN *UpdateAtime,
2359 OUT BOOLEAN *UpdateMtime,
2367 STATIC CONST EFI_TIME ZeroTime = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
2371 Time[0] = &Info->CreateTime;
2372 Time[1] = &Info->LastAccessTime;
2373 Time[2] = &Info->ModificationTime;
2374 NewTime[0] = &NewInfo->CreateTime;
2375 NewTime[1] = &NewInfo->LastAccessTime;
2376 NewTime[2] = &NewInfo->ModificationTime;
2383 for (Idx = 0; Idx <
ARRAY_SIZE (Time); Idx++) {
2387 Change[Idx] =
FALSE;
2390 return EFI_INVALID_PARAMETER;
2405 if (Change[0] && Change[2] && (Seconds[0] != Seconds[2])) {
2406 return EFI_ACCESS_DENIED;
2409 *UpdateAtime =
FALSE;
2410 *UpdateMtime =
FALSE;
2413 *UpdateMtime =
TRUE;
2414 *Mtime = Seconds[0];
2418 *UpdateAtime =
TRUE;
2419 *Atime = Seconds[1];
2423 *UpdateMtime =
TRUE;
2424 *Mtime = Seconds[2];
2462 OUT BOOLEAN *Update,
2467 BOOLEAN IsDirectory;
2468 BOOLEAN IsWriteable;
2469 BOOLEAN WillBeWriteable;
2471 Toggle = Info->Attribute ^ NewInfo->Attribute;
2472 if ((Toggle & ~EFI_FILE_VALID_ATTR) != 0) {
2476 return EFI_ACCESS_DENIED;
2479 if ((Toggle & EFI_FILE_DIRECTORY) != 0) {
2483 return EFI_ACCESS_DENIED;
2486 IsDirectory = (BOOLEAN)((Info->Attribute & EFI_FILE_DIRECTORY) != 0);
2487 IsWriteable = (BOOLEAN)((Info->Attribute & EFI_FILE_READ_ONLY) == 0);
2488 WillBeWriteable = (BOOLEAN)((NewInfo->Attribute & EFI_FILE_READ_ONLY) == 0);
2490 if (IsWriteable == WillBeWriteable) {
2496 if (WillBeWriteable) {
2497 *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RWXU |
2498 VIRTIO_FS_FUSE_MODE_PERM_RWXG |
2499 VIRTIO_FS_FUSE_MODE_PERM_RWXO);
2501 *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |
2502 VIRTIO_FS_FUSE_MODE_PERM_XUSR |
2503 VIRTIO_FS_FUSE_MODE_PERM_RGRP |
2504 VIRTIO_FS_FUSE_MODE_PERM_XGRP |
2505 VIRTIO_FS_FUSE_MODE_PERM_ROTH |
2506 VIRTIO_FS_FUSE_MODE_PERM_XOTH);
2509 if (WillBeWriteable) {
2510 *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |
2511 VIRTIO_FS_FUSE_MODE_PERM_WUSR |
2512 VIRTIO_FS_FUSE_MODE_PERM_RGRP |
2513 VIRTIO_FS_FUSE_MODE_PERM_WGRP |
2514 VIRTIO_FS_FUSE_MODE_PERM_ROTH |
2515 VIRTIO_FS_FUSE_MODE_PERM_WOTH);
2517 *Mode = (VIRTIO_FS_FUSE_MODE_PERM_RUSR |
2518 VIRTIO_FS_FUSE_MODE_PERM_RGRP |
2519 VIRTIO_FS_FUSE_MODE_PERM_ROTH);
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
UINT64 EFIAPI LShiftU64(IN UINT64 Operand, IN UINTN Count)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
CHAR8 *EFIAPI AsciiStrStr(IN CONST CHAR8 *String, IN CONST CHAR8 *SearchString)
INTN EFIAPI CompareMem(IN CONST VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID EFIAPI FreePool(IN VOID *Buffer)
VOID *EFIAPI AllocateCopyPool(IN UINTN AllocationSize, IN CONST VOID *Buffer)
EFI_STATUS VirtioFsFuseForget(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId)
EFI_STATUS VirtioFsFuseLookup(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 DirNodeId, IN CHAR8 *Name, OUT UINT64 *NodeId, OUT VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr)
#define ARRAY_SIZE(Array)
#define OFFSET_OF(TYPE, Field)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
UINTN EFIAPI EfiTimeToEpoch(IN EFI_TIME *Time)
VOID EFIAPI EpochToEfiTime(IN UINTN EpochSeconds, OUT EFI_TIME *Time)
BOOLEAN EFIAPI IsTimeValid(IN EFI_TIME *Time)
#define VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE_SIZE(Namelen)
STATIC VOID ParserRewindDot(IN CHAR8 *Buffer, IN OUT UINTN *Position)
EFI_STATUS VirtioFsFuseDirentPlusToEfiFileInfo(IN VIRTIO_FS_FUSE_DIRENTPLUS_RESPONSE *FuseDirent, IN OUT EFI_FILE_INFO *FileInfo)
EFI_STATUS VirtioFsGetFuseModeUpdate(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT32 *Mode)
VOID EFIAPI VirtioFsExitBoot(IN EFI_EVENT ExitBootEvent, IN VOID *VirtioFsAsVoid)
STATIC VOID ParserStripSlash(IN CHAR8 *Buffer, IN OUT UINTN *Position)
STATIC VOID ParserCopy(OUT CHAR8 *Buffer, IN OUT UINTN *Position, IN UINTN Size, IN CHAR8 Char8)
VOID VirtioFsGetFuseSizeUpdate(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT64 *Size)
EFI_STATUS VirtioFsGetBasename(IN CHAR8 *Path, OUT CHAR16 *Basename OPTIONAL, IN OUT UINTN *BasenameSize)
EFI_STATUS VirtioFsFuseCheckResponse(IN VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList, IN UINT64 RequestId, OUT UINTN *TailBufferFill)
VOID VirtioFsUninit(IN OUT VIRTIO_FS *VirtioFs)
EFI_STATUS VirtioFsLookupMostSpecificParentDir(IN OUT VIRTIO_FS *VirtioFs, IN OUT CHAR8 *Path, OUT UINT64 *DirNodeId, OUT CHAR8 **LastComponent)
EFI_STATUS VirtioFsFuseNewRequest(IN OUT VIRTIO_FS *VirtioFs, OUT VIRTIO_FS_FUSE_REQUEST *Request, IN UINT32 RequestSize, IN VIRTIO_FS_FUSE_OPCODE Opcode, IN UINT64 NodeId)
EFI_STATUS VirtioFsInit(IN OUT VIRTIO_FS *VirtioFs)
EFI_STATUS VirtioFsAppendPath(IN CHAR8 *LhsPath8, IN CHAR16 *RhsPath16, OUT CHAR8 **ResultPath8, OUT BOOLEAN *RootEscape)
EFI_STATUS VirtioFsSgListsSubmit(IN OUT VIRTIO_FS *VirtioFs, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL)
STATIC EFI_STATUS VirtioFsReadConfig(IN VIRTIO_DEVICE_PROTOCOL *Virtio, OUT VIRTIO_FS_CONFIG *Config)
EFI_STATUS VirtioFsGetFuseTimeUpdates(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *UpdateAtime, OUT BOOLEAN *UpdateMtime, OUT UINT64 *Atime, OUT UINT64 *Mtime)
EFI_STATUS VirtioFsFuseAttrToEfiFileInfo(IN VIRTIO_FS_FUSE_ATTRIBUTES_RESPONSE *FuseAttr, OUT EFI_FILE_INFO *FileInfo)
EFI_STATUS VirtioFsErrnoToEfiStatus(IN INT32 Errno)
EFI_STATUS VirtioFsSgListsValidate(IN VIRTIO_FS *VirtioFs, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *RequestSgList, IN OUT VIRTIO_FS_SCATTER_GATHER_LIST *ResponseSgList OPTIONAL)
EFI_STATUS VirtioFsComposeRenameDestination(IN CHAR8 *LhsPath8, IN CHAR16 *RhsPath16, OUT CHAR8 **ResultPath8, OUT BOOLEAN *RootEscape)
STATIC VOID ParserRewindDotDot(IN CHAR8 *Buffer, IN OUT UINTN *Position, OUT BOOLEAN *RootEscape)
EFI_STATUS EFIAPI VirtioMapAllBytesInSharedBuffer(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN VIRTIO_MAP_OPERATION Operation, IN VOID *HostAddress, IN UINTN NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping)
VOID EFIAPI VirtioAppendDesc(IN OUT VRING *Ring, IN UINT64 BufferDeviceAddress, IN UINT32 BufferSize, IN UINT16 Flags, IN OUT DESC_INDICES *Indices)
EFI_STATUS EFIAPI VirtioFlush(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN UINT16 VirtQueueId, IN OUT VRING *Ring, IN DESC_INDICES *Indices, OUT UINT32 *UsedLen OPTIONAL)
EFI_STATUS EFIAPI VirtioRingMap(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN VRING *Ring, OUT UINT64 *RingBaseShift, OUT VOID **Mapping)
EFI_STATUS EFIAPI Virtio10WriteFeatures(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN UINT64 Features, IN OUT UINT8 *DeviceStatus)
VOID EFIAPI VirtioPrepare(IN OUT VRING *Ring, OUT DESC_INDICES *Indices)
EFI_STATUS EFIAPI VirtioRingInit(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN UINT16 QueueSize, OUT VRING *Ring)
VOID EFIAPI VirtioRingUninit(IN VIRTIO_DEVICE_PROTOCOL *VirtIo, IN OUT VRING *Ring)
EFI_TIME ModificationTime