mirror of
https://github.com/winfsp/winfsp.git
synced 2025-04-23 08:53:01 -05:00
winfsp-tests: memfs
This commit is contained in:
parent
a7479b2b29
commit
f7ce154278
@ -9,6 +9,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#define MEMFS_SECTOR_SIZE 512
|
#define MEMFS_SECTOR_SIZE 512
|
||||||
|
#define MEMFS_SECTORS_PER_ALLOCATION_UNIT 1
|
||||||
|
|
||||||
static inline
|
static inline
|
||||||
UINT64 MemfsGetSystemTime(VOID)
|
UINT64 MemfsGetSystemTime(VOID)
|
||||||
@ -191,7 +192,22 @@ static NTSTATUS GetVolumeInfo(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
FSP_FSCTL_TRANSACT_REQ *Request,
|
FSP_FSCTL_TRANSACT_REQ *Request,
|
||||||
FSP_FSCTL_VOLUME_INFO *VolumeInfo)
|
FSP_FSCTL_VOLUME_INFO *VolumeInfo)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_DEVICE_REQUEST;
|
MEMFS *Memfs = (MEMFS *)FileSystem->UserContext;
|
||||||
|
MEMFS_FILE_NODE *RootNode;
|
||||||
|
ULONG AllocationUnits = Memfs->MaxFileSize / (MEMFS_SECTOR_SIZE * MEMFS_SECTORS_PER_ALLOCATION_UNIT);
|
||||||
|
|
||||||
|
RootNode = MemfsFileNodeMapGet(Memfs->FileNodeMap, L"");
|
||||||
|
if (0 == RootNode)
|
||||||
|
return STATUS_DISK_CORRUPT_ERROR;
|
||||||
|
|
||||||
|
VolumeInfo->TotalAllocationUnits = Memfs->MaxFileNodes * AllocationUnits;
|
||||||
|
VolumeInfo->AvailableAllocationUnits =
|
||||||
|
(Memfs->MaxFileNodes - MemfsFileNodeMapCount(Memfs->FileNodeMap)) * AllocationUnits;
|
||||||
|
VolumeInfo->VolumeCreationTime = RootNode->FileInfo.CreationTime;
|
||||||
|
VolumeInfo->VolumeLabelLength = sizeof L"MEMFS" - sizeof(WCHAR);
|
||||||
|
memcpy(VolumeInfo->VolumeLabel, L"Memfs", VolumeInfo->VolumeLabelLength);
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS GetSecurity(FSP_FILE_SYSTEM *FileSystem,
|
static NTSTATUS GetSecurity(FSP_FILE_SYSTEM *FileSystem,
|
||||||
@ -438,7 +454,13 @@ NTSTATUS MemfsCreate(ULONG Flags, ULONG FileInfoTimeout,
|
|||||||
|
|
||||||
memset(&VolumeParams, 0, sizeof VolumeParams);
|
memset(&VolumeParams, 0, sizeof VolumeParams);
|
||||||
VolumeParams.SectorSize = MEMFS_SECTOR_SIZE;
|
VolumeParams.SectorSize = MEMFS_SECTOR_SIZE;
|
||||||
|
VolumeParams.SectorsPerAllocationUnit = MEMFS_SECTORS_PER_ALLOCATION_UNIT;
|
||||||
|
VolumeParams.SerialNumber = (UINT32)(MemfsGetSystemTime() / (10000 * 1000));
|
||||||
VolumeParams.FileInfoTimeout = FileInfoTimeout;
|
VolumeParams.FileInfoTimeout = FileInfoTimeout;
|
||||||
|
VolumeParams.CaseSensitiveSearch = 1;
|
||||||
|
VolumeParams.CasePreservedNames = 1;
|
||||||
|
VolumeParams.UnicodeOnDisk = 1;
|
||||||
|
VolumeParams.PersistentAcls = 1;
|
||||||
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), L"\\memfs\\share");
|
wcscpy_s(VolumeParams.Prefix, sizeof VolumeParams.Prefix / sizeof(WCHAR), L"\\memfs\\share");
|
||||||
|
|
||||||
Result = FspFileSystemCreate(DevicePath, &VolumeParams, &MemfsInterface, &Memfs->FileSystem);
|
Result = FspFileSystemCreate(DevicePath, &VolumeParams, &MemfsInterface, &Memfs->FileSystem);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user