Skip to content

Commit bc2378a

Browse files
gigaherzHeisSpiter
authored andcommitted
[CDFS_NEW] Use CdAcquireForCreateSection from the old driver in place of the newer CdFilterCallbackAcquireForCreateSection.
1 parent 5429771 commit bc2378a

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

drivers/filesystems/cdfs_new/cdinit.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,9 @@ Return Value:
191191
sizeof(FS_FILTER_CALLBACKS) );
192192

193193
FilterCallbacks.SizeOfFsFilterCallbacks = sizeof(FS_FILTER_CALLBACKS);
194+
#ifndef __REACTOS__
194195
FilterCallbacks.PreAcquireForSectionSynchronization = CdFilterCallbackAcquireForCreateSection;
196+
#endif
195197

196198
Status = FsRtlRegisterFileSystemFilterCallbacks( DriverObject,
197199
&FilterCallbacks );
@@ -357,11 +359,15 @@ Return Value:
357359
CdFastIoDispatch.FastIoUnlockSingle = CdFastUnlockSingle; // UnlockSingle
358360
CdFastIoDispatch.FastIoUnlockAll = CdFastUnlockAll; // UnlockAll
359361
CdFastIoDispatch.FastIoUnlockAllByKey = CdFastUnlockAllByKey; // UnlockAllByKey
362+
#ifndef __REACTOS__
360363
//
361364
// This callback has been replaced by CdFilterCallbackAcquireForCreateSection.
362365
//
363366

364367
CdFastIoDispatch.AcquireFileForNtCreateSection = NULL;
368+
#else
369+
CdFastIoDispatch.AcquireFileForNtCreateSection = CdAcquireForCreateSection;
370+
#endif
365371
CdFastIoDispatch.ReleaseFileForNtCreateSection = CdReleaseForCreateSection;
366372
CdFastIoDispatch.FastIoQueryNetworkOpenInfo = CdFastQueryNetworkInfo; // QueryNetworkInfo
367373

drivers/filesystems/cdfs_new/cdprocs.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,13 +1121,21 @@ CdReleaseFromCache (
11211121
_Inout_ PFCB Fcb
11221122
);
11231123

1124+
#ifndef __REACTOS__
11241125
_Requires_lock_held_(_Global_critical_region_)
11251126
NTSTATUS
11261127
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
11271128
CdFilterCallbackAcquireForCreateSection (
11281129
_In_ PFS_FILTER_CALLBACK_DATA CallbackData,
11291130
_Unreferenced_parameter_ PVOID *CompletionContext
11301131
);
1132+
#else
1133+
VOID
1134+
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
1135+
CdAcquireForCreateSection (
1136+
IN PFILE_OBJECT FileObject
1137+
);
1138+
#endif
11311139

11321140
_Function_class_(FAST_IO_RELEASE_FILE)
11331141
_Requires_lock_held_(_Global_critical_region_)

drivers/filesystems/cdfs_new/resrcsup.c

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@ Module Name:
2323

2424
#ifdef ALLOC_PRAGMA
2525
#pragma alloc_text(PAGE, CdAcquireForCache)
26+
#ifndef __REACTOS__
2627
#pragma alloc_text(PAGE, CdFilterCallbackAcquireForCreateSection)
28+
#else
29+
#pragma alloc_text(PAGE, CdAcquireForCreateSection)
30+
#endif
2731
#pragma alloc_text(PAGE, CdAcquireResource)
2832
#pragma alloc_text(PAGE, CdNoopAcquire)
2933
#pragma alloc_text(PAGE, CdNoopRelease)
@@ -274,6 +278,7 @@ Return Value:
274278
}
275279

276280

281+
#ifndef __REACTOS__
277282
_Requires_lock_held_(_Global_critical_region_)
278283
NTSTATUS
279284
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
@@ -356,6 +361,55 @@ Return Value:
356361

357362
UNREFERENCED_PARAMETER( CompletionContext );
358363
}
364+
#else
365+
VOID
366+
NTAPI /* ReactOS Change: GCC Does not support STDCALL by default */
367+
CdAcquireForCreateSection (
368+
IN PFILE_OBJECT FileObject
369+
)
370+
371+
/*++
372+
373+
Routine Description:
374+
375+
This is the callback routine for MM to use to acquire the file exclusively.
376+
377+
Arguments:
378+
379+
FileObject - File object for a Cdfs stream.
380+
381+
Return Value:
382+
383+
None
384+
385+
--*/
386+
387+
{
388+
PAGED_CODE();
389+
390+
391+
//
392+
// Get the Fcb resource exclusively.
393+
//
394+
395+
ExAcquireResourceExclusiveLite( &((PFCB) FileObject->FsContext)->FcbNonpaged->FcbResource,
396+
TRUE );
397+
398+
//
399+
// Take the File resource shared. We need this later on when MM calls
400+
// QueryStandardInfo to get the file size.
401+
//
402+
// If we don't use StarveExclusive, then we can get wedged behind an
403+
// exclusive waiter who is waiting on someone else holding it shared in the
404+
// read->initializecachemap path (which calls createsection) who is in turn
405+
// waiting on us to finish the create section.
406+
//
407+
408+
ExAcquireSharedStarveExclusive( ((PFCB) FileObject->FsContext)->Resource,
409+
TRUE );
410+
}
411+
#endif
412+
359413

360414

361415
_Function_class_(FAST_IO_RELEASE_FILE)

0 commit comments

Comments
 (0)