mirror of
				https://github.com/winfsp/winfsp.git
				synced 2025-10-30 19:48:38 -05:00 
			
		
		
		
	sys: FspFsvolSetDispositionInformation: ignore FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK flag
This commit is contained in:
		| @@ -1513,16 +1513,26 @@ retry: | |||||||
|         if (!NT_SUCCESS(Result)) |         if (!NT_SUCCESS(Result)) | ||||||
|             goto unlock_exit; |             goto unlock_exit; | ||||||
|  |  | ||||||
|         if (FlagOn(DispositionFlags, FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK)) |         /* | ||||||
|         { |          * Make sure no process is mapping the file as an image. | ||||||
|             /* make sure no process is mapping the file as an image */ |          * | ||||||
|  |          * NOTE: | ||||||
|  |          *     Turns out that NTFS always does this test, even when | ||||||
|  |          *     FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK has been specified. | ||||||
|  |          *     If MmFlushImageSection fails (e.g. an actively running EXE) then | ||||||
|  |          *     it only allows the deletion to go through when a secondary hard | ||||||
|  |          *     link is being deleted. | ||||||
|  |          * | ||||||
|  |          *     Since WinFsp does not support hard links, we will go ahead and | ||||||
|  |          *     ignore the FILE_DISPOSITION_FORCE_IMAGE_SECTION_CHECK flag and | ||||||
|  |          *     always respect the result of MmFlushImageSection. | ||||||
|  |          */ | ||||||
|         Success = MmFlushImageSection(FileObject->SectionObjectPointer, MmFlushForDelete); |         Success = MmFlushImageSection(FileObject->SectionObjectPointer, MmFlushForDelete); | ||||||
|         if (!Success) |         if (!Success) | ||||||
|         { |         { | ||||||
|             Result = STATUS_CANNOT_DELETE; |             Result = STATUS_CANNOT_DELETE; | ||||||
|             goto unlock_exit; |             goto unlock_exit; | ||||||
|         } |         } | ||||||
|         } |  | ||||||
|  |  | ||||||
|         if (FlagOn(DispositionFlags, FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE)) |         if (FlagOn(DispositionFlags, FILE_DISPOSITION_IGNORE_READONLY_ATTRIBUTE)) | ||||||
|         { |         { | ||||||
|   | |||||||
| @@ -200,6 +200,27 @@ static void exec_delete_dotest(ULONG Flags, PWSTR Prefix, ULONG FileInfoTimeout) | |||||||
|     ASSERT(!DeleteFileW(FilePath)); |     ASSERT(!DeleteFileW(FilePath)); | ||||||
|     ASSERT(ERROR_ACCESS_DENIED == GetLastError()); |     ASSERT(ERROR_ACCESS_DENIED == GetLastError()); | ||||||
|  |  | ||||||
|  |     { | ||||||
|  |         MY_FILE_DISPOSITION_INFO_EX DispositionInfo; | ||||||
|  |         HANDLE Handle; | ||||||
|  |         BOOLEAN Success; | ||||||
|  |         Handle = CreateFileW(FilePath, | ||||||
|  |             DELETE, FILE_SHARE_DELETE, 0, | ||||||
|  |             OPEN_EXISTING, 0, 0); | ||||||
|  |         if (INVALID_HANDLE_VALUE != Handle) | ||||||
|  |         { | ||||||
|  |             DispositionInfo.Disposition = FILE_DISPOSITION_DELETE | FILE_DISPOSITION_POSIX_SEMANTICS; | ||||||
|  |             Success = SetFileInformationByHandle(Handle, | ||||||
|  |                 21/*FileDispositionInfoEx*/, &DispositionInfo, sizeof DispositionInfo); | ||||||
|  |             ASSERT(!Success); | ||||||
|  |             ASSERT( | ||||||
|  |                 ERROR_INVALID_PARAMETER == GetLastError() || | ||||||
|  |                 ERROR_ACCESS_DENIED == GetLastError()); | ||||||
|  |             Success = CloseHandle(Handle); | ||||||
|  |             ASSERT(Success); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     WaitHelper(Process, 1000); |     WaitHelper(Process, 1000); | ||||||
|  |  | ||||||
|     ASSERT(DeleteFileW(FilePath)); |     ASSERT(DeleteFileW(FilePath)); | ||||||
|   | |||||||
| @@ -154,6 +154,10 @@ typedef struct | |||||||
| { | { | ||||||
|     BOOLEAN Disposition; |     BOOLEAN Disposition; | ||||||
| } MY_FILE_DISPOSITION_INFO; | } MY_FILE_DISPOSITION_INFO; | ||||||
|  | typedef struct | ||||||
|  | { | ||||||
|  |     UINT32 Disposition; | ||||||
|  | } MY_FILE_DISPOSITION_INFO_EX; | ||||||
|  |  | ||||||
| void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | void *memfs_start_ex(ULONG Flags, ULONG FileInfoTimeout); | ||||||
| void *memfs_start(ULONG Flags); | void *memfs_start(ULONG Flags); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user