mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-22 08:23:05 -05:00
sys: canonicalize filename related functions under the name FspFileName*
This commit is contained in:
parent
096b2dabde
commit
0534225662
@ -173,10 +173,10 @@
|
||||
<ClCompile Include="..\..\src\sys\ioq.c" />
|
||||
<ClCompile Include="..\..\src\sys\lockctl.c" />
|
||||
<ClCompile Include="..\..\src\sys\meta.c" />
|
||||
<ClCompile Include="..\..\src\sys\name.c" />
|
||||
<ClCompile Include="..\..\src\sys\read.c" />
|
||||
<ClCompile Include="..\..\src\sys\security.c" />
|
||||
<ClCompile Include="..\..\src\sys\shutdown.c" />
|
||||
<ClCompile Include="..\..\src\sys\strutil.c" />
|
||||
<ClCompile Include="..\..\src\sys\util.c" />
|
||||
<ClCompile Include="..\..\src\sys\volinfo.c" />
|
||||
<ClCompile Include="..\..\src\sys\volume.c" />
|
||||
|
@ -92,7 +92,7 @@
|
||||
<ClCompile Include="..\..\src\sys\callbacks.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\src\sys\strutil.c">
|
||||
<ClCompile Include="..\..\src\sys\name.c">
|
||||
<Filter>Source</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
|
@ -179,7 +179,7 @@ static NTSTATUS FspFsvolCreateNoLock(
|
||||
FSP_FILE_NODE *FileNode, *RelatedFileNode;
|
||||
FSP_FILE_DESC *FileDesc;
|
||||
UNICODE_STRING MainFileName = { 0 }, StreamPart = { 0 };
|
||||
ULONG StreamType = FspUnicodePathStreamTypeNone;
|
||||
ULONG StreamType = FspFileNameStreamTypeNone;
|
||||
FSP_FSCTL_TRANSACT_REQ *Request;
|
||||
|
||||
/* cannot open files by fileid */
|
||||
@ -276,7 +276,7 @@ static NTSTATUS FspFsvolCreateNoLock(
|
||||
ASSERT(NT_SUCCESS(Result));
|
||||
|
||||
/* check filename validity */
|
||||
if (!FspUnicodePathIsValid(&FileNode->FileName,
|
||||
if (!FspFileNameIsValid(&FileNode->FileName,
|
||||
FsvolDeviceExtension->VolumeParams.NamedStreams ? &StreamPart : 0,
|
||||
&StreamType))
|
||||
{
|
||||
@ -334,7 +334,7 @@ static NTSTATUS FspFsvolCreateNoLock(
|
||||
}
|
||||
|
||||
/* if a $DATA stream type, this cannot be a directory */
|
||||
if (FspUnicodePathStreamTypeData == StreamType)
|
||||
if (FspFileNameStreamTypeData == StreamType)
|
||||
{
|
||||
if (FlagOn(CreateOptions, FILE_DIRECTORY_FILE))
|
||||
{
|
||||
@ -756,7 +756,7 @@ NTSTATUS FspFsvolCreateComplete(
|
||||
{
|
||||
UNICODE_STRING Suffix;
|
||||
|
||||
FspUnicodePathSuffix(&FileNode->FileName, &FileNode->FileName, &Suffix);
|
||||
FspFileNameSuffix(&FileNode->FileName, &FileNode->FileName, &Suffix);
|
||||
}
|
||||
|
||||
/* populate the FileNode/FileDesc fields from the Response */
|
||||
|
@ -185,7 +185,7 @@ static NTSTATUS FspFsvolQueryDirectoryCopy(
|
||||
Match = MatchAll;
|
||||
if (!Match)
|
||||
{
|
||||
Result = FspIsNameInExpression(DirectoryPattern, &FileName, CaseInsensitive, 0, &Match);
|
||||
Result = FspFileNameInExpression(DirectoryPattern, &FileName, CaseInsensitive, 0, &Match);
|
||||
if (!NT_SUCCESS(Result))
|
||||
return Result;
|
||||
}
|
||||
@ -626,7 +626,7 @@ static NTSTATUS FspFsvolQueryDirectory(
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* check that FileName is valid (if supplied) */
|
||||
if (0 != FileName && !FspUnicodePathIsValidPattern(FileName))
|
||||
if (0 != FileName && !FspFileNameIsValidPattern(FileName))
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
/* is this an allowed file information class? */
|
||||
|
@ -428,16 +428,16 @@ BOOLEAN FspExpirationTimeValid2(UINT64 ExpirationTime, UINT64 CurrentTime)
|
||||
return CurrentTime < ExpirationTime;
|
||||
}
|
||||
|
||||
/* string utility */
|
||||
/* names */
|
||||
enum
|
||||
{
|
||||
FspUnicodePathStreamTypeNone = 0,
|
||||
FspUnicodePathStreamTypeData = 1,
|
||||
FspFileNameStreamTypeNone = 0,
|
||||
FspFileNameStreamTypeData = 1,
|
||||
};
|
||||
BOOLEAN FspUnicodePathIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType);
|
||||
BOOLEAN FspUnicodePathIsValidPattern(PUNICODE_STRING Pattern);
|
||||
VOID FspUnicodePathSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix);
|
||||
NTSTATUS FspIsNameInExpression(
|
||||
BOOLEAN FspFileNameIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType);
|
||||
BOOLEAN FspFileNameIsValidPattern(PUNICODE_STRING Pattern);
|
||||
VOID FspFileNameSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix);
|
||||
NTSTATUS FspFileNameInExpression(
|
||||
PUNICODE_STRING Expression,
|
||||
PUNICODE_STRING Name,
|
||||
BOOLEAN IgnoreCase,
|
||||
|
@ -1231,7 +1231,7 @@ VOID FspFileNodeNotifyChange(FSP_FILE_NODE *FileNode,
|
||||
UNICODE_STRING Parent, Suffix;
|
||||
FSP_FILE_NODE *ParentNode;
|
||||
|
||||
FspUnicodePathSuffix(&FileNode->FileName, &Parent, &Suffix);
|
||||
FspFileNameSuffix(&FileNode->FileName, &Parent, &Suffix);
|
||||
|
||||
switch (Action)
|
||||
{
|
||||
@ -1428,7 +1428,7 @@ NTSTATUS FspMainFileOpen(
|
||||
PFILE_OBJECT MainFileObject;
|
||||
|
||||
/* assert that the supplied name is actually a main file name */
|
||||
ASSERT(FspUnicodePathIsValid(MainFileName, 0, 0));
|
||||
ASSERT(FspFileNameIsValid(MainFileName, 0, 0));
|
||||
|
||||
*PMainFileHandle = 0;
|
||||
*PMainFileObject = 0;
|
||||
|
@ -1116,7 +1116,7 @@ static NTSTATUS FspFsvolSetRenameInformation(
|
||||
if (FileNode->IsRootDirectory)
|
||||
/* cannot rename root directory */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
if (!FspUnicodePathIsValid(&FileNode->FileName, 0, 0))
|
||||
if (!FspFileNameIsValid(&FileNode->FileName, 0, 0))
|
||||
/* cannot rename streams (WinFsp limitation) */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
|
||||
@ -1134,14 +1134,14 @@ static NTSTATUS FspFsvolSetRenameInformation(
|
||||
if (0 != TargetFileNode)
|
||||
Remain = TargetFileNode->FileName;
|
||||
else
|
||||
FspUnicodePathSuffix(&FileNode->FileName, &Remain, &Suffix);
|
||||
FspFileNameSuffix(&FileNode->FileName, &Remain, &Suffix);
|
||||
|
||||
Suffix.Length = Suffix.MaximumLength = (USHORT)Info->FileNameLength;
|
||||
Suffix.Buffer = Info->FileName;
|
||||
if (L'\\' == Suffix.Buffer[0])
|
||||
FspUnicodePathSuffix(&Suffix, &NewFileName, &Suffix);
|
||||
FspFileNameSuffix(&Suffix, &NewFileName, &Suffix);
|
||||
|
||||
if (!FspUnicodePathIsValid(&Remain, 0, 0) || !FspUnicodePathIsValid(&Suffix, 0, 0))
|
||||
if (!FspFileNameIsValid(&Remain, 0, 0) || !FspFileNameIsValid(&Suffix, 0, 0))
|
||||
{
|
||||
/* cannot rename streams (WinFsp limitation) */
|
||||
Result = STATUS_INVALID_PARAMETER;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file sys/strutil.c
|
||||
* @file sys/name.c
|
||||
*
|
||||
* @copyright 2015-2016 Bill Zissimopoulos
|
||||
*/
|
||||
@ -17,10 +17,10 @@
|
||||
|
||||
#include <sys/driver.h>
|
||||
|
||||
BOOLEAN FspUnicodePathIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType);
|
||||
BOOLEAN FspUnicodePathIsValidPattern(PUNICODE_STRING Pattern);
|
||||
VOID FspUnicodePathSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix);
|
||||
NTSTATUS FspIsNameInExpression(
|
||||
BOOLEAN FspFileNameIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType);
|
||||
BOOLEAN FspFileNameIsValidPattern(PUNICODE_STRING Pattern);
|
||||
VOID FspFileNameSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix);
|
||||
NTSTATUS FspFileNameInExpression(
|
||||
PUNICODE_STRING Expression,
|
||||
PUNICODE_STRING Name,
|
||||
BOOLEAN IgnoreCase,
|
||||
@ -28,13 +28,13 @@ NTSTATUS FspIsNameInExpression(
|
||||
PBOOLEAN PResult);
|
||||
|
||||
#ifdef ALLOC_PRAGMA
|
||||
#pragma alloc_text(PAGE, FspUnicodePathIsValid)
|
||||
#pragma alloc_text(PAGE, FspUnicodePathIsValidPattern)
|
||||
#pragma alloc_text(PAGE, FspUnicodePathSuffix)
|
||||
#pragma alloc_text(PAGE, FspIsNameInExpression)
|
||||
#pragma alloc_text(PAGE, FspFileNameIsValid)
|
||||
#pragma alloc_text(PAGE, FspFileNameIsValidPattern)
|
||||
#pragma alloc_text(PAGE, FspFileNameSuffix)
|
||||
#pragma alloc_text(PAGE, FspFileNameInExpression)
|
||||
#endif
|
||||
|
||||
BOOLEAN FspUnicodePathIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType)
|
||||
BOOLEAN FspFileNameIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart, PULONG StreamType)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
@ -112,7 +112,7 @@ BOOLEAN FspUnicodePathIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart,
|
||||
|
||||
ASSERT(0 != StreamPart && 0 != StreamType);
|
||||
|
||||
*StreamType = FspUnicodePathStreamTypeNone;
|
||||
*StreamType = FspFileNameStreamTypeNone;
|
||||
|
||||
/* if we had no stream type the path is valid if there was an actual stream name */
|
||||
if (0 == StreamTypeStr)
|
||||
@ -126,14 +126,14 @@ BOOLEAN FspUnicodePathIsValid(PUNICODE_STRING Path, PUNICODE_STRING StreamPart,
|
||||
L'T' == StreamTypeStr[3] &&
|
||||
L'A' == StreamTypeStr[4])
|
||||
{
|
||||
*StreamType = FspUnicodePathStreamTypeData;
|
||||
*StreamType = FspFileNameStreamTypeData;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN FspUnicodePathIsValidPattern(PUNICODE_STRING Path)
|
||||
BOOLEAN FspFileNameIsValidPattern(PUNICODE_STRING Path)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
@ -170,7 +170,7 @@ BOOLEAN FspUnicodePathIsValidPattern(PUNICODE_STRING Path)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
VOID FspUnicodePathSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix)
|
||||
VOID FspFileNameSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE_STRING Suffix)
|
||||
{
|
||||
PAGED_CODE();
|
||||
|
||||
@ -202,7 +202,7 @@ VOID FspUnicodePathSuffix(PUNICODE_STRING Path, PUNICODE_STRING Remain, PUNICODE
|
||||
Suffix->Buffer = SuffixBgn;
|
||||
}
|
||||
|
||||
NTSTATUS FspIsNameInExpression(
|
||||
NTSTATUS FspFileNameInExpression(
|
||||
PUNICODE_STRING Expression,
|
||||
PUNICODE_STRING Name,
|
||||
BOOLEAN IgnoreCase,
|
Loading…
x
Reference in New Issue
Block a user