61 IN BOOLEAN IsSizeByInfoPresent,
65 UINTN NameFieldByteOffset;
67 UINTN NameFieldChar16s;
74 ASSERT (MinimumStructSize >=
sizeof (CHAR16));
75 NameFieldByteOffset = MinimumStructSize -
sizeof (CHAR16);
77 if (IsSizeByInfoPresent) {
78 ASSERT (MinimumStructSize >=
sizeof (UINT64) +
sizeof (CHAR16));
79 ASSERT (NameFieldByteOffset >=
sizeof (UINT64));
86 if (SizeByProtocolCaller < MinimumStructSize) {
87 return EFI_BAD_BUFFER_SIZE;
94 if (IsSizeByInfoPresent) {
98 if (*SizeByInfo != SizeByProtocolCaller) {
99 return EFI_INVALID_PARAMETER;
110 ASSERT (SizeByProtocolCaller >= NameFieldByteOffset);
111 NameFieldBytes = SizeByProtocolCaller - NameFieldByteOffset;
112 ASSERT (NameFieldBytes >=
sizeof (CHAR16));
113 if (NameFieldBytes %
sizeof (CHAR16) != 0) {
114 return EFI_INVALID_PARAMETER;
120 NameFieldChar16s = NameFieldBytes /
sizeof (CHAR16);
121 ASSERT (NameFieldChar16s >= 1);
123 NameField = (CHAR16 *)((UINT8 *)Buffer + NameFieldByteOffset);
124 if (NameField[NameFieldChar16s - 1] != L
'\0') {
125 return EFI_INVALID_PARAMETER;
176 IN CHAR16 *NewFileName
183 UINT64 OldParentDirNodeId;
184 CHAR8 *OldLastComponent;
185 UINT64 NewParentDirNodeId;
186 CHAR8 *NewLastComponent;
188 VirtioFs = VirtioFsFile->OwnerFs;
193 if (
AsciiStrCmp (VirtioFsFile->CanonicalPathname,
"/") == 0) {
194 if (
StrCmp (NewFileName, L
"") == 0) {
201 return EFI_ACCESS_DENIED;
208 VirtioFsFile->CanonicalPathname,
213 if (EFI_ERROR (Status)) {
218 Status = EFI_NOT_FOUND;
219 goto FreeDestination;
226 if (
AsciiStrCmp (VirtioFsFile->CanonicalPathname, Destination) == 0) {
228 goto FreeDestination;
235 if (VirtioFsFile->IsDirectory) {
239 PathLen =
AsciiStrLen (VirtioFsFile->CanonicalPathname);
243 OtherFile = VIRTIO_FS_FILE_FROM_OPEN_FILES_ENTRY (OpenFilesEntry);
244 if ((OtherFile != VirtioFsFile) &&
246 VirtioFsFile->CanonicalPathname,
247 OtherFile->CanonicalPathname,
250 ((OtherFile->CanonicalPathname[PathLen] ==
'\0') ||
251 (OtherFile->CanonicalPathname[PathLen] ==
'/')))
258 Status = EFI_ACCESS_DENIED;
259 goto FreeDestination;
267 if (!VirtioFsFile->IsOpenForWriting) {
268 Status = EFI_ACCESS_DENIED;
269 goto FreeDestination;
278 VirtioFsFile->CanonicalPathname,
282 if (EFI_ERROR (Status)) {
283 goto FreeDestination;
292 if (EFI_ERROR (Status)) {
293 goto ForgetOldParentDirNodeId;
306 if (EFI_ERROR (Status)) {
307 goto ForgetNewParentDirNodeId;
313 FreePool (VirtioFsFile->CanonicalPathname);
314 VirtioFsFile->CanonicalPathname = Destination;
321ForgetNewParentDirNodeId:
322 if (NewParentDirNodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
326ForgetOldParentDirNodeId:
327 if (OldParentDirNodeId != VIRTIO_FS_FUSE_ROOT_DIR_NODE_ID) {
332 if (Destination !=
NULL) {
371 BOOLEAN UpdateFileSize;
380 VirtioFs = VirtioFsFile->OwnerFs;
387 if (EFI_ERROR (Status)) {
392 if (EFI_ERROR (Status)) {
399 if (VirtioFsFile->IsDirectory) {
400 UpdateFileSize =
FALSE;
418 if (EFI_ERROR (Status)) {
428 if (EFI_ERROR (Status)) {
435 if (!UpdateFileSize && !UpdateAtime && !UpdateMtime && !UpdateMode) {
443 if (!VirtioFsFile->IsOpenForWriting &&
444 (UpdateFileSize || UpdateAtime || UpdateMtime))
446 return EFI_ACCESS_DENIED;
454 VirtioFsFile->NodeId,
455 UpdateFileSize ? &FileSize :
NULL,
456 UpdateAtime ? &Atime :
NULL,
457 UpdateMtime ? &Mtime :
NULL,
458 UpdateMode ? &Mode :
NULL
478 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
492 if (EFI_ERROR (Status)) {
502 if (EFI_ERROR (Status)) {
534 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
535 VirtioFs = VirtioFsFile->OwnerFs;
549 if (EFI_ERROR (Status)) {
553 FileSystemInfo = Buffer;
567 return EFI_WRITE_PROTECTED;
586 VirtioFsFile = VIRTIO_FS_FILE_FROM_SIMPLE_FILE (This);
587 VirtioFs = VirtioFsFile->OwnerFs;
601 if (EFI_ERROR (Status)) {
605 FileSystemVolumeLabel = Buffer;
616 return EFI_WRITE_PROTECTED;
621VirtioFsSimpleFileSetInfo (
628 if (
CompareGuid (InformationType, &gEfiFileInfoGuid)) {
632 if (
CompareGuid (InformationType, &gEfiFileSystemInfoGuid)) {
636 if (
CompareGuid (InformationType, &gEfiFileSystemVolumeLabelInfoIdGuid)) {
640 return EFI_UNSUPPORTED;
INTN EFIAPI StrCmp(IN CONST CHAR16 *FirstString, IN CONST CHAR16 *SecondString)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
#define BASE_LIST_FOR_EACH(Entry, ListHead)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
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 VirtioFsFuseRename(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 OldParentNodeId, IN CHAR8 *OldName, IN UINT64 NewParentNodeId, IN CHAR8 *NewName)
EFI_STATUS VirtioFsFuseSetAttr(IN OUT VIRTIO_FS *VirtioFs, IN UINT64 NodeId, IN UINT64 *Size OPTIONAL, IN UINT64 *Atime OPTIONAL, IN UINT64 *Mtime OPTIONAL, IN UINT32 *Mode OPTIONAL)
#define OFFSET_OF(TYPE, Field)
EFI_FILE_INFO * FileInfo(IN EFI_FILE_HANDLE FHand)
STATIC EFI_STATUS SetFileInfo(IN EFI_FILE_PROTOCOL *This, IN UINTN BufferSize, IN VOID *Buffer)
STATIC EFI_STATUS UpdateAttributes(IN OUT VIRTIO_FS_FILE *VirtioFsFile, IN EFI_FILE_INFO *NewFileInfo)
STATIC EFI_STATUS SetFileSystemInfo(IN EFI_FILE_PROTOCOL *This, IN UINTN BufferSize, IN VOID *Buffer)
STATIC EFI_STATUS SetFileSystemVolumeLabelInfo(IN EFI_FILE_PROTOCOL *This, IN UINTN BufferSize, IN VOID *Buffer)
STATIC EFI_STATUS Rename(IN OUT VIRTIO_FS_FILE *VirtioFsFile, IN CHAR16 *NewFileName)
STATIC EFI_STATUS ValidateInfoStructure(IN UINTN SizeByProtocolCaller, IN UINTN MinimumStructSize, IN BOOLEAN IsSizeByInfoPresent, IN VOID *Buffer)
EFI_STATUS VirtioFsGetFuseModeUpdate(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT32 *Mode)
VOID VirtioFsGetFuseSizeUpdate(IN EFI_FILE_INFO *Info, IN EFI_FILE_INFO *NewInfo, OUT BOOLEAN *Update, OUT UINT64 *Size)
EFI_STATUS VirtioFsLookupMostSpecificParentDir(IN OUT VIRTIO_FS *VirtioFs, IN OUT CHAR8 *Path, OUT UINT64 *DirNodeId, OUT CHAR8 **LastComponent)
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 VirtioFsComposeRenameDestination(IN CHAR8 *LhsPath8, IN CHAR16 *RhsPath16, OUT CHAR8 **ResultPath8, OUT BOOLEAN *RootEscape)