2013-09-11 23:19:20 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Named Pipe FileSystem
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: drivers/filesystems/npfs/prefxsup.c
|
|
|
|
* PURPOSE: Pipes Prefixes Support
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
2013-09-07 15:32:29 +00:00
|
|
|
#include "npfs.h"
|
|
|
|
|
2013-09-12 00:05:54 +00:00
|
|
|
// File ID number for NPFS bugchecking support
|
|
|
|
#define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_PREFXSUP)
|
|
|
|
|
2013-09-11 23:19:20 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
2013-09-07 15:32:29 +00:00
|
|
|
PNP_FCB
|
|
|
|
NTAPI
|
|
|
|
NpFindPrefix(IN PUNICODE_STRING Name,
|
|
|
|
IN ULONG CaseInsensitiveIndex,
|
|
|
|
IN PUNICODE_STRING Prefix)
|
|
|
|
{
|
|
|
|
PUNICODE_PREFIX_TABLE_ENTRY Entry;
|
|
|
|
PNP_FCB Fcb;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
Entry = RtlFindUnicodePrefix(&NpVcb->PrefixTable,
|
|
|
|
Name,
|
|
|
|
CaseInsensitiveIndex);
|
2013-09-12 00:05:54 +00:00
|
|
|
if (!Entry) NpBugCheck(0, 0, 0);
|
2013-09-07 15:32:29 +00:00
|
|
|
|
|
|
|
Fcb = CONTAINING_RECORD(Entry, NP_FCB, PrefixTableEntry);
|
|
|
|
|
|
|
|
Prefix->Length = Name->Length - Fcb->FullName.Length;
|
|
|
|
Prefix->MaximumLength = Prefix->Length;
|
|
|
|
Prefix->Buffer = &Name->Buffer[Fcb->FullName.Length / sizeof(WCHAR)];
|
|
|
|
|
|
|
|
if ((Prefix->Length) && (Prefix->Buffer[0] == OBJ_NAME_PATH_SEPARATOR))
|
|
|
|
{
|
|
|
|
Prefix->Length -= sizeof(WCHAR);
|
|
|
|
Prefix->MaximumLength -= sizeof(WCHAR);
|
|
|
|
++Prefix->Buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Fcb;
|
|
|
|
}
|
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NpFindRelativePrefix(IN PNP_DCB Dcb,
|
|
|
|
IN PUNICODE_STRING Name,
|
|
|
|
IN ULONG CaseInsensitiveIndex,
|
|
|
|
IN PUNICODE_STRING Prefix,
|
|
|
|
OUT PNP_FCB *FoundFcb)
|
|
|
|
{
|
|
|
|
PWCHAR Buffer;
|
|
|
|
PNP_FCB Fcb;
|
|
|
|
UNICODE_STRING RootName;
|
|
|
|
USHORT Length, MaximumLength;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
Length = Name->Length;
|
|
|
|
MaximumLength = Length + sizeof(OBJ_NAME_PATH_SEPARATOR) + sizeof(UNICODE_NULL);
|
|
|
|
if (MaximumLength < Length) return STATUS_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
ASSERT(Dcb->NodeType == NPFS_NTC_ROOT_DCB);
|
|
|
|
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
Buffer = ExAllocatePoolWithTag(PagedPool, MaximumLength, NPFS_NAME_BLOCK_TAG);
|
2013-09-07 15:32:29 +00:00
|
|
|
if (!Buffer)
|
|
|
|
{
|
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
*Buffer = OBJ_NAME_PATH_SEPARATOR;
|
|
|
|
RtlCopyMemory(Buffer + 1, Name->Buffer, Length);
|
|
|
|
Buffer[(Length / sizeof(WCHAR)) + 1] = UNICODE_NULL;
|
|
|
|
|
|
|
|
RootName.Length = Length + sizeof(OBJ_NAME_PATH_SEPARATOR);
|
|
|
|
RootName.MaximumLength = MaximumLength;
|
|
|
|
RootName.Buffer = Buffer;
|
|
|
|
|
|
|
|
Fcb = NpFindPrefix(&RootName, CaseInsensitiveIndex, Prefix);
|
|
|
|
|
|
|
|
ExFreePool(Buffer);
|
|
|
|
|
|
|
|
Prefix->Buffer = &Name->Buffer[(Length - Prefix->Length) / sizeof(WCHAR)];
|
|
|
|
*FoundFcb = Fcb;
|
|
|
|
|
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2013-09-11 23:19:20 +00:00
|
|
|
/* EOF */
|