mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[NTOSKRNL]
- Implemented FsRtlPTeardownPerFileObjectContexts(), FsRtlLookupPerFileObjectContext(), FsRtlInsertPerFileObjectContext(), FsRtlRemovePerFileObjectContext() - Stubplemented IoGetFileObjectFilterContext(), IoChangeFileObjectFilterContext() - Add support of per file object filter context to IopDeleteFile() As ReactOS doesn't support file objects extensions, this doesn't work (blame Aleksey) - yet svn path=/trunk/; revision=49758
This commit is contained in:
parent
c70bf13d93
commit
1ab061dba1
4 changed files with 213 additions and 10 deletions
|
@ -20,9 +20,26 @@ typedef struct _FILE_OBJECT_FILTER_CONTEXTS
|
||||||
LIST_ENTRY FilterContexts;
|
LIST_ENTRY FilterContexts;
|
||||||
} FILE_OBJECT_FILTER_CONTEXTS, *PFILE_OBJECT_FILTER_CONTEXTS;
|
} FILE_OBJECT_FILTER_CONTEXTS, *PFILE_OBJECT_FILTER_CONTEXTS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
VOID
|
VOID
|
||||||
|
NTAPI
|
||||||
FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject)
|
FsRtlPTeardownPerFileObjectContexts(IN PFILE_OBJECT FileObject)
|
||||||
{
|
{
|
||||||
|
PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
|
||||||
|
|
||||||
|
ASSERT(FileObject);
|
||||||
|
|
||||||
|
if (!(FOContext = IoGetFileObjectFilterContext(FileObject)))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERT(IoChangeFileObjectFilterContext(FileObject, FOContext, FALSE) == STATUS_SUCCESS);
|
||||||
|
ASSERT(IsListEmpty(&(FOContext->FilterContexts)));
|
||||||
|
|
||||||
|
ExFreePoolWithTag(FOContext, 'FOCX');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +67,7 @@ FsRtlIsPagingFile(IN PFILE_OBJECT FileObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
PFSRTL_PER_FILEOBJECT_CONTEXT
|
PFSRTL_PER_FILEOBJECT_CONTEXT
|
||||||
NTAPI
|
NTAPI
|
||||||
|
@ -58,8 +75,47 @@ FsRtlLookupPerFileObjectContext(IN PFILE_OBJECT FileObject,
|
||||||
IN PVOID OwnerId OPTIONAL,
|
IN PVOID OwnerId OPTIONAL,
|
||||||
IN PVOID InstanceId OPTIONAL)
|
IN PVOID InstanceId OPTIONAL)
|
||||||
{
|
{
|
||||||
KeBugCheck(FILE_SYSTEM);
|
PLIST_ENTRY NextEntry;
|
||||||
return FALSE;
|
PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
|
||||||
|
PFSRTL_PER_FILEOBJECT_CONTEXT TmpPerFOContext, PerFOContext = NULL;
|
||||||
|
|
||||||
|
if (!FileObject || !(FOContext = IoGetFileObjectFilterContext(FileObject)))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExAcquireFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
|
||||||
|
/* If list is empty, no need to browse it */
|
||||||
|
if (!IsListEmpty(&(FOContext->FilterContexts)))
|
||||||
|
{
|
||||||
|
for (NextEntry = FOContext->FilterContexts.Flink;
|
||||||
|
NextEntry != &(FOContext->FilterContexts);
|
||||||
|
NextEntry = NextEntry->Flink)
|
||||||
|
{
|
||||||
|
/* If we don't have any criteria for search, first entry will be enough */
|
||||||
|
if (!OwnerId && !InstanceId)
|
||||||
|
{
|
||||||
|
PerFOContext = (PFSRTL_PER_FILEOBJECT_CONTEXT)NextEntry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Else, we've to find something that matches with the parameters. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TmpPerFOContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_FILEOBJECT_CONTEXT, Links);
|
||||||
|
if ((InstanceId && TmpPerFOContext->InstanceId == InstanceId && TmpPerFOContext->OwnerId == OwnerId) ||
|
||||||
|
(OwnerId && TmpPerFOContext->OwnerId == OwnerId))
|
||||||
|
{
|
||||||
|
PerFOContext = TmpPerFOContext;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExReleaseFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
|
||||||
|
return PerFOContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -105,21 +161,62 @@ FsRtlLookupPerStreamContextInternal(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ExReleaseFastMutex(AdvFcbHeader->FastMutex);
|
ExReleaseFastMutex(AdvFcbHeader->FastMutex);
|
||||||
|
|
||||||
return PerStreamContext;
|
return PerStreamContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
NTSTATUS
|
NTSTATUS
|
||||||
NTAPI
|
NTAPI
|
||||||
FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject,
|
FsRtlInsertPerFileObjectContext(IN PFILE_OBJECT FileObject,
|
||||||
IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr)
|
IN PFSRTL_PER_FILEOBJECT_CONTEXT Ptr)
|
||||||
{
|
{
|
||||||
KeBugCheck(FILE_SYSTEM);
|
PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
|
||||||
|
if (!FileObject)
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION))
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
FOContext = IoGetFileObjectFilterContext(FileObject);
|
||||||
|
if (!FOContext)
|
||||||
|
{
|
||||||
|
FOContext = ExAllocatePoolWithTag(NonPagedPool, sizeof(FILE_OBJECT_FILTER_CONTEXTS), 'FOCX');
|
||||||
|
if (!FOContext)
|
||||||
|
{
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExInitializeFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
InitializeListHead(&(FOContext->FilterContexts));
|
||||||
|
|
||||||
|
if (!IoChangeFileObjectFilterContext(FileObject, FOContext, TRUE))
|
||||||
|
{
|
||||||
|
ExFreePoolWithTag(FOContext, 'FOCX');
|
||||||
|
|
||||||
|
FOContext = IoGetFileObjectFilterContext(FileObject);
|
||||||
|
if (!FOContext)
|
||||||
|
{
|
||||||
|
ASSERT(FALSE);
|
||||||
|
return STATUS_UNSUCCESSFUL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExAcquireFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
InsertHeadList(&(FOContext->FilterContexts), &(Ptr->Links));
|
||||||
|
ExReleaseFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -142,16 +239,61 @@ FsRtlInsertPerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader,
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
PFSRTL_PER_FILEOBJECT_CONTEXT
|
PFSRTL_PER_FILEOBJECT_CONTEXT
|
||||||
NTAPI
|
NTAPI
|
||||||
FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT PerFileObjectContext,
|
FsRtlRemovePerFileObjectContext(IN PFILE_OBJECT FileObject,
|
||||||
IN PVOID OwnerId OPTIONAL,
|
IN PVOID OwnerId OPTIONAL,
|
||||||
IN PVOID InstanceId OPTIONAL)
|
IN PVOID InstanceId OPTIONAL)
|
||||||
{
|
{
|
||||||
KeBugCheck(FILE_SYSTEM);
|
PLIST_ENTRY NextEntry;
|
||||||
return NULL;
|
PFILE_OBJECT_FILTER_CONTEXTS FOContext = NULL;
|
||||||
|
PFSRTL_PER_FILEOBJECT_CONTEXT TmpPerFOContext, PerFOContext = NULL;
|
||||||
|
|
||||||
|
if (!FileObject || !(FOContext = IoGetFileObjectFilterContext(FileObject)))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ExAcquireFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
|
||||||
|
/* If list is empty, no need to browse it */
|
||||||
|
if (!IsListEmpty(&(FOContext->FilterContexts)))
|
||||||
|
{
|
||||||
|
for (NextEntry = FOContext->FilterContexts.Flink;
|
||||||
|
NextEntry != &(FOContext->FilterContexts);
|
||||||
|
NextEntry = NextEntry->Flink)
|
||||||
|
{
|
||||||
|
/* If we don't have any criteria for search, first entry will be enough */
|
||||||
|
if (!OwnerId && !InstanceId)
|
||||||
|
{
|
||||||
|
PerFOContext = (PFSRTL_PER_FILEOBJECT_CONTEXT)NextEntry;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
/* Else, we've to find something that matches with the parameters. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TmpPerFOContext = CONTAINING_RECORD(NextEntry, FSRTL_PER_FILEOBJECT_CONTEXT, Links);
|
||||||
|
if ((InstanceId && TmpPerFOContext->InstanceId == InstanceId && TmpPerFOContext->OwnerId == OwnerId) ||
|
||||||
|
(OwnerId && TmpPerFOContext->OwnerId == OwnerId))
|
||||||
|
{
|
||||||
|
PerFOContext = TmpPerFOContext;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Finally remove entry from list */
|
||||||
|
if (PerFOContext)
|
||||||
|
{
|
||||||
|
RemoveEntryList(&(PerFOContext->Links));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ExReleaseFastMutex(&(FOContext->FilterContextsMutex));
|
||||||
|
|
||||||
|
return PerFOContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -197,6 +339,7 @@ FsRtlRemovePerStreamContext(IN PFSRTL_ADVANCED_FCB_HEADER AdvFcbHeader,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally remove entry from list */
|
/* Finally remove entry from list */
|
||||||
if (PerStreamContext)
|
if (PerStreamContext)
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,15 @@ FsRtlInitSystem(
|
||||||
VOID
|
VOID
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// File contexts Routines
|
||||||
|
//
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
FsRtlPTeardownPerFileObjectContexts(
|
||||||
|
IN PFILE_OBJECT FileObject
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Global data inside the File System Runtime Library
|
// Global data inside the File System Runtime Library
|
||||||
//
|
//
|
||||||
|
|
|
@ -1155,6 +1155,20 @@ IopCloseFile(
|
||||||
IN ULONG SystemHandleCount
|
IN ULONG SystemHandleCount
|
||||||
);
|
);
|
||||||
|
|
||||||
|
PVOID
|
||||||
|
NTAPI
|
||||||
|
IoGetFileObjectFilterContext(
|
||||||
|
IN PFILE_OBJECT FileObject
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
IoChangeFileObjectFilterContext(
|
||||||
|
IN PFILE_OBJECT FileObject,
|
||||||
|
IN PVOID FilterContext,
|
||||||
|
IN BOOLEAN Define
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// I/O Timer Routines
|
// I/O Timer Routines
|
||||||
//
|
//
|
||||||
|
|
|
@ -1049,6 +1049,13 @@ IopDeleteFile(IN PVOID ObjectBody)
|
||||||
ExFreePool(FileObject->CompletionContext);
|
ExFreePool(FileObject->CompletionContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check if the FO had extension */
|
||||||
|
if (FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION)
|
||||||
|
{
|
||||||
|
/* Release filter context structure if any */
|
||||||
|
FsRtlPTeardownPerFileObjectContexts(FileObject);
|
||||||
|
}
|
||||||
|
|
||||||
/* Check if dereference has been done yet */
|
/* Check if dereference has been done yet */
|
||||||
if (!DereferenceDone)
|
if (!DereferenceDone)
|
||||||
{
|
{
|
||||||
|
@ -1610,6 +1617,36 @@ IopQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PVOID
|
||||||
|
NTAPI
|
||||||
|
IoGetFileObjectFilterContext(IN PFILE_OBJECT FileObject)
|
||||||
|
{
|
||||||
|
if (FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION)
|
||||||
|
{
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
/* FIXME: return NULL for the moment ~ */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
IoChangeFileObjectFilterContext(IN PFILE_OBJECT FileObject,
|
||||||
|
IN PVOID FilterContext,
|
||||||
|
IN BOOLEAN Define)
|
||||||
|
{
|
||||||
|
if (!(FileObject->Flags & FO_FILE_OBJECT_HAS_EXTENSION))
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
UNIMPLEMENTED;
|
||||||
|
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue