mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Implemented file system change notification.
svn path=/trunk/; revision=2418
This commit is contained in:
parent
116270d2e0
commit
909d916ca5
2 changed files with 102 additions and 35 deletions
|
@ -1,6 +1,6 @@
|
||||||
#ifndef _INCLUDE_DDK_IOFUNCS_H
|
#ifndef _INCLUDE_DDK_IOFUNCS_H
|
||||||
#define _INCLUDE_DDK_IOFUNCS_H
|
#define _INCLUDE_DDK_IOFUNCS_H
|
||||||
/* $Id: iofuncs.h,v 1.26 2001/09/16 13:19:31 chorns Exp $ */
|
/* $Id: iofuncs.h,v 1.27 2001/12/05 12:13:12 ekohl Exp $ */
|
||||||
|
|
||||||
/* --- EXPORTED BY NTOSKRNL --- */
|
/* --- EXPORTED BY NTOSKRNL --- */
|
||||||
|
|
||||||
|
@ -1067,14 +1067,14 @@ IoUnregisterFileSystem (
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
IoUnregisterFsRegistrationChange (
|
IoUnregisterFsRegistrationChange (
|
||||||
DWORD Unknown0,
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
DWORD Unknown1
|
IN PFSDNOTIFICATIONPROC FSDNotificationProc
|
||||||
);
|
);
|
||||||
#endif // (_WIN32_WINNT >= 0x0400)
|
#endif // (_WIN32_WINNT >= 0x0400)
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
IoUnregisterShutdownNotification (
|
IoUnregisterShutdownNotification (
|
||||||
PDEVICE_OBJECT DeviceObject
|
IN PDEVICE_OBJECT DeviceObject
|
||||||
);
|
);
|
||||||
VOID
|
VOID
|
||||||
STDCALL
|
STDCALL
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: fs.c,v 1.19 2001/11/02 22:22:33 hbirr Exp $
|
/* $Id: fs.c,v 1.20 2001/12/05 12:14:13 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -22,21 +22,35 @@
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject;
|
PDEVICE_OBJECT DeviceObject;
|
||||||
LIST_ENTRY Entry;
|
LIST_ENTRY Entry;
|
||||||
} FILE_SYSTEM_OBJECT;
|
} FILE_SYSTEM_OBJECT;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
LIST_ENTRY FsChangeNotifyList;
|
||||||
|
PDRIVER_OBJECT DriverObject;
|
||||||
|
PFSDNOTIFICATIONPROC FSDNotificationProc;
|
||||||
|
} FS_CHANGE_NOTIFY_ENTRY, *PFS_CHANGE_NOTIFY_ENTRY;
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
static KSPIN_LOCK FileSystemListLock;
|
static KSPIN_LOCK FileSystemListLock;
|
||||||
static LIST_ENTRY FileSystemListHead;
|
static LIST_ENTRY FileSystemListHead;
|
||||||
|
|
||||||
#define TAG_FILE_SYSTEM TAG('F', 'S', 'Y', 'S')
|
static KSPIN_LOCK FsChangeNotifyListLock;
|
||||||
|
static LIST_ENTRY FsChangeNotifyListHead;
|
||||||
|
|
||||||
|
#define TAG_FILE_SYSTEM TAG('F', 'S', 'Y', 'S')
|
||||||
|
#define TAG_FS_CHANGE_NOTIFY TAG('F', 'S', 'C', 'N')
|
||||||
|
|
||||||
|
|
||||||
|
static VOID IopNotifyFileSystemChange(PDEVICE_OBJECT DeviceObject,
|
||||||
|
BOOLEAN DriverActive);
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
NTSTATUS
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
|
||||||
NtFsControlFile (
|
NtFsControlFile (
|
||||||
IN HANDLE DeviceHandle,
|
IN HANDLE DeviceHandle,
|
||||||
IN HANDLE EventHandle OPTIONAL,
|
IN HANDLE EventHandle OPTIONAL,
|
||||||
|
@ -118,8 +132,11 @@ NtFsControlFile (
|
||||||
|
|
||||||
VOID IoInitFileSystemImplementation(VOID)
|
VOID IoInitFileSystemImplementation(VOID)
|
||||||
{
|
{
|
||||||
InitializeListHead(&FileSystemListHead);
|
InitializeListHead(&FileSystemListHead);
|
||||||
KeInitializeSpinLock(&FileSystemListLock);
|
KeInitializeSpinLock(&FileSystemListLock);
|
||||||
|
|
||||||
|
InitializeListHead(&FsChangeNotifyListHead);
|
||||||
|
KeInitializeSpinLock(&FsChangeNotifyListLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID IoShutdownRegisteredFileSystems(VOID)
|
VOID IoShutdownRegisteredFileSystems(VOID)
|
||||||
|
@ -246,7 +263,8 @@ NTSTATUS IoTryToMountStorageDevice(PDEVICE_OBJECT DeviceObject)
|
||||||
return(STATUS_UNRECOGNIZED_VOLUME);
|
return(STATUS_UNRECOGNIZED_VOLUME);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
VOID STDCALL
|
||||||
|
IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
FILE_SYSTEM_OBJECT* fs;
|
FILE_SYSTEM_OBJECT* fs;
|
||||||
|
|
||||||
|
@ -256,12 +274,14 @@ VOID STDCALL IoRegisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||||
TAG_FILE_SYSTEM);
|
TAG_FILE_SYSTEM);
|
||||||
assert(fs!=NULL);
|
assert(fs!=NULL);
|
||||||
|
|
||||||
fs->DeviceObject = DeviceObject;
|
fs->DeviceObject = DeviceObject;
|
||||||
ExInterlockedInsertTailList(&FileSystemListHead,&fs->Entry,
|
ExInterlockedInsertTailList(&FileSystemListHead,&fs->Entry,
|
||||||
&FileSystemListLock);
|
&FileSystemListLock);
|
||||||
|
IopNotifyFileSystemChange(DeviceObject, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID STDCALL IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
VOID STDCALL
|
||||||
|
IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
KIRQL oldlvl;
|
KIRQL oldlvl;
|
||||||
PLIST_ENTRY current_entry;
|
PLIST_ENTRY current_entry;
|
||||||
|
@ -279,6 +299,7 @@ VOID STDCALL IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||||
RemoveEntryList(current_entry);
|
RemoveEntryList(current_entry);
|
||||||
ExFreePool(current);
|
ExFreePool(current);
|
||||||
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
|
KeReleaseSpinLock(&FileSystemListLock,oldlvl);
|
||||||
|
IopNotifyFileSystemChange(DeviceObject, FALSE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_entry = current_entry->Flink;
|
current_entry = current_entry->Flink;
|
||||||
|
@ -303,11 +324,8 @@ VOID STDCALL IoUnregisterFileSystem(PDEVICE_OBJECT DeviceObject)
|
||||||
* NOTE
|
* NOTE
|
||||||
* From Bo Branten's ntifs.h v13.
|
* From Bo Branten's ntifs.h v13.
|
||||||
*/
|
*/
|
||||||
PDEVICE_OBJECT
|
PDEVICE_OBJECT STDCALL
|
||||||
STDCALL
|
IoGetBaseFileSystemDeviceObject(IN PFILE_OBJECT FileObject)
|
||||||
IoGetBaseFileSystemDeviceObject (
|
|
||||||
IN PFILE_OBJECT FileObject
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT DeviceObject = NULL;
|
PDEVICE_OBJECT DeviceObject = NULL;
|
||||||
PVPB Vpb = NULL;
|
PVPB Vpb = NULL;
|
||||||
|
@ -347,27 +365,76 @@ IoGetBaseFileSystemDeviceObject (
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NTSTATUS
|
static VOID
|
||||||
STDCALL
|
IopNotifyFileSystemChange(PDEVICE_OBJECT DeviceObject,
|
||||||
IoRegisterFsRegistrationChange (
|
BOOLEAN DriverActive)
|
||||||
IN PDRIVER_OBJECT DriverObject,
|
|
||||||
IN PFSDNOTIFICATIONPROC FSDNotificationProc
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PFS_CHANGE_NOTIFY_ENTRY ChangeEntry;
|
||||||
return (STATUS_NOT_IMPLEMENTED);
|
PLIST_ENTRY Entry;
|
||||||
|
KIRQL oldlvl;
|
||||||
|
|
||||||
|
KeAcquireSpinLock(&FsChangeNotifyListLock,&oldlvl);
|
||||||
|
Entry = FsChangeNotifyListHead.Flink;
|
||||||
|
while (Entry != &FsChangeNotifyListHead)
|
||||||
|
{
|
||||||
|
ChangeEntry = CONTAINING_RECORD(Entry, FS_CHANGE_NOTIFY_ENTRY, FsChangeNotifyList);
|
||||||
|
|
||||||
|
(ChangeEntry->FSDNotificationProc)(DeviceObject, DriverActive);
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
}
|
||||||
|
KeReleaseSpinLock(&FsChangeNotifyListLock,oldlvl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
VOID
|
NTSTATUS STDCALL
|
||||||
STDCALL
|
IoRegisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject,
|
||||||
IoUnregisterFsRegistrationChange (
|
IN PFSDNOTIFICATIONPROC FSDNotificationProc)
|
||||||
DWORD Unknown0,
|
|
||||||
DWORD Unknown1
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
UNIMPLEMENTED;
|
PFS_CHANGE_NOTIFY_ENTRY Entry;
|
||||||
|
|
||||||
|
Entry = ExAllocatePoolWithTag(NonPagedPool,
|
||||||
|
sizeof(FS_CHANGE_NOTIFY_ENTRY),
|
||||||
|
TAG_FS_CHANGE_NOTIFY);
|
||||||
|
if (Entry == NULL)
|
||||||
|
return(STATUS_INSUFFICIENT_RESOURCES);
|
||||||
|
|
||||||
|
Entry->DriverObject = DriverObject;
|
||||||
|
Entry->FSDNotificationProc = FSDNotificationProc;
|
||||||
|
|
||||||
|
ExInterlockedInsertHeadList(&FsChangeNotifyListHead,
|
||||||
|
&Entry->FsChangeNotifyList,
|
||||||
|
&FsChangeNotifyListLock);
|
||||||
|
|
||||||
|
return(STATUS_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
IoUnregisterFsRegistrationChange(IN PDRIVER_OBJECT DriverObject,
|
||||||
|
IN PFSDNOTIFICATIONPROC FSDNotificationProc)
|
||||||
|
{
|
||||||
|
PFS_CHANGE_NOTIFY_ENTRY ChangeEntry;
|
||||||
|
PLIST_ENTRY Entry;
|
||||||
|
KIRQL oldlvl;
|
||||||
|
|
||||||
|
Entry = FsChangeNotifyListHead.Flink;
|
||||||
|
while (Entry != &FsChangeNotifyListHead)
|
||||||
|
{
|
||||||
|
ChangeEntry = CONTAINING_RECORD(Entry, FS_CHANGE_NOTIFY_ENTRY, FsChangeNotifyList);
|
||||||
|
if (ChangeEntry->DriverObject == DriverObject &&
|
||||||
|
ChangeEntry->FSDNotificationProc == FSDNotificationProc)
|
||||||
|
{
|
||||||
|
KeAcquireSpinLock(&FsChangeNotifyListLock,&oldlvl);
|
||||||
|
RemoveEntryList(Entry);
|
||||||
|
KeReleaseSpinLock(&FsChangeNotifyListLock,oldlvl);
|
||||||
|
|
||||||
|
ExFreePool(Entry);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue