mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 00:43:00 -05:00
winfsp-tests: memfs
This commit is contained in:
parent
240c914728
commit
5d558334cd
@ -176,6 +176,7 @@
|
|||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
<WarningLevel Condition="'$(Configuration)|$(Platform)'=='Release|x64'">TurnOffAllWarnings</WarningLevel>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\mount-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c" />
|
||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
<ClCompile Include="..\..\..\tst\winfsp-tests\timeout-test.c" />
|
||||||
@ -183,6 +184,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\ext\tlib\testsuite.h" />
|
<ClInclude Include="..\..\..\ext\tlib\testsuite.h" />
|
||||||
|
<ClInclude Include="..\..\..\tst\winfsp-tests\memfs.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\winfsp_dll.vcxproj">
|
<ProjectReference Include="..\winfsp_dll.vcxproj">
|
||||||
|
@ -25,10 +25,16 @@
|
|||||||
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c">
|
<ClCompile Include="..\..\..\tst\winfsp-tests\path-test.c">
|
||||||
<Filter>Source</Filter>
|
<Filter>Source</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\..\tst\winfsp-tests\memfs.c">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
<ClInclude Include="..\..\..\ext\tlib\testsuite.h">
|
||||||
<Filter>Source\tlib</Filter>
|
<Filter>Source\tlib</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\..\tst\winfsp-tests\memfs.h">
|
||||||
|
<Filter>Source</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -178,4 +178,5 @@ FSP_API VOID FspPathCombine(PWSTR Prefix, PWSTR Suffix);
|
|||||||
*/
|
*/
|
||||||
FSP_API NTSTATUS FspNtStatusFromWin32(DWORD Error);
|
FSP_API NTSTATUS FspNtStatusFromWin32(DWORD Error);
|
||||||
FSP_API VOID FspDebugLog(const char *format, ...);
|
FSP_API VOID FspDebugLog(const char *format, ...);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
97
tst/winfsp-tests/memfs.c
Normal file
97
tst/winfsp-tests/memfs.c
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
* @file memfs.c
|
||||||
|
*
|
||||||
|
* @copyright 2015 Bill Zissimopoulos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "memfs.h"
|
||||||
|
|
||||||
|
static NTSTATUS GetSecurity(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
PWSTR FileName, PDWORD PFileAttributes,
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor, SIZE_T *PSecurityDescriptorSize)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS Create(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
FSP_FSCTL_TRANSACT_REQ *Request,
|
||||||
|
FSP_FILE_NODE_INFO *Info)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS Open(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
FSP_FSCTL_TRANSACT_REQ *Request,
|
||||||
|
FSP_FILE_NODE_INFO *Info)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static NTSTATUS Overwrite(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
FSP_FSCTL_TRANSACT_REQ *Request,
|
||||||
|
PVOID FileNode, DWORD FileAttributes, BOOLEAN ReplaceFileAttributes,
|
||||||
|
FSP_FILE_SIZE_INFO *Info)
|
||||||
|
{
|
||||||
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID Cleanup(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
FSP_FSCTL_TRANSACT_REQ *Request,
|
||||||
|
PVOID FileNode, BOOLEAN Delete)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID Close(FSP_FILE_SYSTEM *FileSystem,
|
||||||
|
FSP_FSCTL_TRANSACT_REQ *Request,
|
||||||
|
PVOID FileNode)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static FSP_FILE_SYSTEM_INTERFACE MemfsInterface =
|
||||||
|
{
|
||||||
|
.GetSecurity = GetSecurity,
|
||||||
|
.Create = Create,
|
||||||
|
.Open = Open,
|
||||||
|
.Overwrite = Overwrite,
|
||||||
|
.Cleanup = Cleanup,
|
||||||
|
.Close = Close,
|
||||||
|
};
|
||||||
|
|
||||||
|
NTSTATUS MemfsCreate(PWSTR DevicePath, ULONG MaxFileNodes, ULONG MaxFileSize,
|
||||||
|
MEMFS **PMemfs)
|
||||||
|
{
|
||||||
|
NTSTATUS Result;
|
||||||
|
FSP_FSCTL_VOLUME_PARAMS VolumeParams;
|
||||||
|
MEMFS *Memfs;
|
||||||
|
|
||||||
|
*PMemfs = 0;
|
||||||
|
|
||||||
|
Memfs = malloc(sizeof *Memfs);
|
||||||
|
if (0 == Memfs)
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
|
memset(Memfs, 0, sizeof *Memfs);
|
||||||
|
Memfs->MaxFileNodes = MaxFileNodes;
|
||||||
|
Memfs->MaxFileSize = MaxFileSize;
|
||||||
|
|
||||||
|
memset(&VolumeParams, 0, sizeof VolumeParams);
|
||||||
|
VolumeParams.FileNameRequired = TRUE;
|
||||||
|
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), L"\\memfs\\share");
|
||||||
|
|
||||||
|
Result = FspFileSystemCreate(DevicePath, &VolumeParams, &MemfsInterface, &Memfs->FileSystem);
|
||||||
|
if (!NT_SUCCESS(Result))
|
||||||
|
{
|
||||||
|
free(Memfs);
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
*PMemfs = Memfs;
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID MemfsDelete(MEMFS *Memfs)
|
||||||
|
{
|
||||||
|
FspFileSystemDelete(Memfs->FileSystem);
|
||||||
|
free(Memfs);
|
||||||
|
}
|
23
tst/winfsp-tests/memfs.h
Normal file
23
tst/winfsp-tests/memfs.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
/**
|
||||||
|
* @file memfs.h
|
||||||
|
*
|
||||||
|
* @copyright 2015 Bill Zissimopoulos
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MEMFS_H_INCLUDED
|
||||||
|
#define MEMFS_H_INCLUDED
|
||||||
|
|
||||||
|
#include <winfsp/winfsp.h>
|
||||||
|
|
||||||
|
typedef struct _MEMFS
|
||||||
|
{
|
||||||
|
FSP_FILE_SYSTEM *FileSystem;
|
||||||
|
ULONG MaxFileNodes;
|
||||||
|
ULONG MaxFileSize;
|
||||||
|
} MEMFS;
|
||||||
|
|
||||||
|
NTSTATUS MemfsCreate(PWSTR DevicePath, ULONG MaxFileNodes, ULONG MaxFileSize,
|
||||||
|
MEMFS **PMemfs);
|
||||||
|
VOID MemfsDelete(MEMFS *Memfs);
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user