mirror of
https://github.com/winfsp/winfsp.git
synced 2025-06-08 13:02:10 -05:00
sys: IRP_MJ_SET_INFORMATION: testing
This commit is contained in:
parent
69627c216b
commit
f65e2059e4
@ -47,6 +47,7 @@ FSP_API NTSTATUS FspFileSystemCreate(PWSTR DevicePath,
|
|||||||
FileSystem->Operations[FspFsctlTransactCleanupKind] = FspFileSystemOpCleanup;
|
FileSystem->Operations[FspFsctlTransactCleanupKind] = FspFileSystemOpCleanup;
|
||||||
FileSystem->Operations[FspFsctlTransactCloseKind] = FspFileSystemOpClose;
|
FileSystem->Operations[FspFsctlTransactCloseKind] = FspFileSystemOpClose;
|
||||||
FileSystem->Operations[FspFsctlTransactQueryInformationKind] = FspFileSystemOpQueryInformation;
|
FileSystem->Operations[FspFsctlTransactQueryInformationKind] = FspFileSystemOpQueryInformation;
|
||||||
|
FileSystem->Operations[FspFsctlTransactSetInformationKind] = FspFileSystemOpSetInformation;
|
||||||
FileSystem->Operations[FspFsctlTransactQueryVolumeInformationKind] = FspFileSystemOpQueryVolumeInformation;
|
FileSystem->Operations[FspFsctlTransactQueryVolumeInformationKind] = FspFileSystemOpQueryVolumeInformation;
|
||||||
// !!!: ...
|
// !!!: ...
|
||||||
FileSystem->Interface = Interface;
|
FileSystem->Interface = Interface;
|
||||||
|
@ -523,29 +523,32 @@ static NTSTATUS FspFsvolSetAllocationInformation(PFILE_OBJECT FileObject,
|
|||||||
{
|
{
|
||||||
if (sizeof(FILE_ALLOCATION_INFORMATION) > Length)
|
if (sizeof(FILE_ALLOCATION_INFORMATION) > Length)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
else if (0 == Response)
|
||||||
|
{
|
||||||
|
PFILE_ALLOCATION_INFORMATION Info = (PFILE_ALLOCATION_INFORMATION)Buffer;
|
||||||
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
|
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension =
|
||||||
|
FspFsvolDeviceExtension(FileNode->FsvolDeviceObject);
|
||||||
|
UINT64 AllocationSize = Info->AllocationSize.QuadPart;
|
||||||
|
UINT64 AllocationUnit;
|
||||||
|
BOOLEAN Success;
|
||||||
|
|
||||||
if (0 != Response)
|
AllocationUnit = FsvolDeviceExtension->VolumeParams.SectorSize *
|
||||||
return STATUS_SUCCESS;
|
FsvolDeviceExtension->VolumeParams.SectorsPerAllocationUnit;
|
||||||
|
AllocationSize = (AllocationSize + AllocationUnit - 1) / AllocationUnit * AllocationUnit;
|
||||||
|
Request->Req.SetInformation.Info.Allocation.AllocationSize = AllocationSize;
|
||||||
|
|
||||||
PFILE_ALLOCATION_INFORMATION Info = (PFILE_ALLOCATION_INFORMATION)Buffer;
|
Success = MmCanFileBeTruncated(FileObject->SectionObjectPointer, &Info->AllocationSize);
|
||||||
|
if (!Success)
|
||||||
|
return STATUS_USER_MAPPED_FILE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
|
|
||||||
FSP_FSVOL_DEVICE_EXTENSION *FsvolDeviceExtension =
|
FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.SetInformation.FileInfo);
|
||||||
FspFsvolDeviceExtension(FileObject->DeviceObject);
|
}
|
||||||
UINT64 AllocationSize = Info->AllocationSize.QuadPart;
|
|
||||||
UINT64 AllocationUnit;
|
|
||||||
BOOLEAN Success;
|
|
||||||
|
|
||||||
AllocationUnit = FsvolDeviceExtension->VolumeParams.SectorSize *
|
|
||||||
FsvolDeviceExtension->VolumeParams.SectorsPerAllocationUnit;
|
|
||||||
AllocationSize = (AllocationSize + AllocationUnit - 1) / AllocationUnit * AllocationUnit;
|
|
||||||
Request->Req.SetInformation.Info.Allocation.AllocationSize = AllocationSize;
|
|
||||||
|
|
||||||
Success = MmCanFileBeTruncated(FileObject->SectionObjectPointer, &Info->AllocationSize);
|
|
||||||
if (!Success)
|
|
||||||
return STATUS_USER_MAPPED_FILE;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -560,30 +563,33 @@ static NTSTATUS FspFsvolSetBasicInformation(PFILE_OBJECT FileObject,
|
|||||||
{
|
{
|
||||||
if (sizeof(FILE_BASIC_INFORMATION) > Length)
|
if (sizeof(FILE_BASIC_INFORMATION) > Length)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
else if (0 == Response)
|
||||||
|
{
|
||||||
|
PFILE_BASIC_INFORMATION Info = (PFILE_BASIC_INFORMATION)Buffer;
|
||||||
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
|
UINT32 FileAttributes = Info->FileAttributes;
|
||||||
|
|
||||||
if (0 != Response)
|
if (0 == FileAttributes)
|
||||||
return STATUS_SUCCESS;
|
FileAttributes = ((UINT32)-1);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ClearFlag(FileAttributes, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
if (FileNode->IsDirectory)
|
||||||
|
SetFlag(FileAttributes, FILE_ATTRIBUTE_DIRECTORY);
|
||||||
|
}
|
||||||
|
|
||||||
PFILE_BASIC_INFORMATION Info = (PFILE_BASIC_INFORMATION)Buffer;
|
Request->Req.SetInformation.Info.Basic.FileAttributes = FileAttributes;
|
||||||
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
Request->Req.SetInformation.Info.Basic.CreationTime = Info->CreationTime.QuadPart;
|
||||||
UINT32 FileAttributes = Info->FileAttributes;
|
Request->Req.SetInformation.Info.Basic.LastAccessTime = Info->LastAccessTime.QuadPart;
|
||||||
|
Request->Req.SetInformation.Info.Basic.LastWriteTime = Info->LastWriteTime.QuadPart;
|
||||||
if (0 == FileAttributes)
|
}
|
||||||
FileAttributes = ((UINT32)-1);
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ClearFlag(FileAttributes, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_DIRECTORY);
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
if (FileNode->IsDirectory)
|
|
||||||
SetFlag(FileAttributes, FILE_ATTRIBUTE_DIRECTORY);
|
|
||||||
}
|
|
||||||
|
|
||||||
Request->Req.SetInformation.Info.Basic.FileAttributes = Info->FileAttributes;
|
FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.SetInformation.FileInfo);
|
||||||
Request->Req.SetInformation.Info.Basic.CreationTime = Info->CreationTime.QuadPart;
|
}
|
||||||
Request->Req.SetInformation.Info.Basic.LastAccessTime = Info->LastAccessTime.QuadPart;
|
|
||||||
Request->Req.SetInformation.Info.Basic.LastWriteTime = Info->LastWriteTime.QuadPart;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -598,11 +604,8 @@ static NTSTATUS FspFsvolSetDispositionInformation(PFILE_OBJECT FileObject,
|
|||||||
{
|
{
|
||||||
if (sizeof(FILE_DISPOSITION_INFORMATION) > Length)
|
if (sizeof(FILE_DISPOSITION_INFORMATION) > Length)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
else if (0 == Response)
|
||||||
if (0 == Response)
|
|
||||||
{
|
{
|
||||||
PFILE_DISPOSITION_INFORMATION Info = (PFILE_DISPOSITION_INFORMATION)Buffer;
|
PFILE_DISPOSITION_INFORMATION Info = (PFILE_DISPOSITION_INFORMATION)Buffer;
|
||||||
BOOLEAN Success;
|
BOOLEAN Success;
|
||||||
@ -617,8 +620,6 @@ static NTSTATUS FspFsvolSetDispositionInformation(PFILE_OBJECT FileObject,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Request->Req.SetInformation.Info.Disposition.Delete = Info->DeleteFile;
|
Request->Req.SetInformation.Info.Disposition.Delete = Info->DeleteFile;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -627,9 +628,9 @@ static NTSTATUS FspFsvolSetDispositionInformation(PFILE_OBJECT FileObject,
|
|||||||
|
|
||||||
FileNode->DeletePending = Info->DeleteFile;
|
FileNode->DeletePending = Info->DeleteFile;
|
||||||
FileObject->DeletePending = Info->DeleteFile;
|
FileObject->DeletePending = Info->DeleteFile;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS FspFsvolSetEndOfFileInformation(PFILE_OBJECT FileObject,
|
static NTSTATUS FspFsvolSetEndOfFileInformation(PFILE_OBJECT FileObject,
|
||||||
@ -642,23 +643,26 @@ static NTSTATUS FspFsvolSetEndOfFileInformation(PFILE_OBJECT FileObject,
|
|||||||
{
|
{
|
||||||
if (sizeof(FILE_END_OF_FILE_INFORMATION) > Length)
|
if (sizeof(FILE_END_OF_FILE_INFORMATION) > Length)
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
}
|
}
|
||||||
|
else if (0 == Response)
|
||||||
|
{
|
||||||
|
PFILE_END_OF_FILE_INFORMATION Info = (PFILE_END_OF_FILE_INFORMATION)Buffer;
|
||||||
|
BOOLEAN Success;
|
||||||
|
|
||||||
if (0 != Response)
|
Request->Req.SetInformation.Info.EndOfFile.FileSize = Info->EndOfFile.QuadPart;
|
||||||
return STATUS_SUCCESS;
|
Request->Req.SetInformation.Info.EndOfFile.AdvanceOnly = AdvanceOnly;
|
||||||
|
|
||||||
PFILE_END_OF_FILE_INFORMATION Info = (PFILE_END_OF_FILE_INFORMATION)Buffer;
|
// !!!: REVISIT after better understanding relationship between AllocationSize and FileSize
|
||||||
BOOLEAN Success;
|
Success = MmCanFileBeTruncated(FileObject->SectionObjectPointer, &Info->EndOfFile);
|
||||||
|
if (!Success)
|
||||||
|
return STATUS_USER_MAPPED_FILE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FSP_FILE_NODE *FileNode = FileObject->FsContext;
|
||||||
|
|
||||||
Request->Req.SetInformation.Info.EndOfFile.FileSize = Info->EndOfFile.QuadPart;
|
FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.SetInformation.FileInfo);
|
||||||
Request->Req.SetInformation.Info.EndOfFile.AdvanceOnly = AdvanceOnly;
|
}
|
||||||
|
|
||||||
// !!!: REVISIT after better understanding relationship between AllocationSize and FileSize
|
|
||||||
Success = MmCanFileBeTruncated(FileObject->SectionObjectPointer, &Info->EndOfFile);
|
|
||||||
if (!Success)
|
|
||||||
return STATUS_USER_MAPPED_FILE;
|
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -816,18 +820,15 @@ NTSTATUS FspFsvolSetInformationComplete(
|
|||||||
switch (FileInformationClass)
|
switch (FileInformationClass)
|
||||||
{
|
{
|
||||||
case FileAllocationInformation:
|
case FileAllocationInformation:
|
||||||
FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.SetInformation.FileInfo);
|
|
||||||
Result = FspFsvolSetAllocationInformation(FileObject, Buffer, Length, Request, Response);
|
Result = FspFsvolSetAllocationInformation(FileObject, Buffer, Length, Request, Response);
|
||||||
break;
|
break;
|
||||||
case FileBasicInformation:
|
case FileBasicInformation:
|
||||||
FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.SetInformation.FileInfo);
|
|
||||||
Result = FspFsvolSetBasicInformation(FileObject, Buffer, Length, Request, Response);
|
Result = FspFsvolSetBasicInformation(FileObject, Buffer, Length, Request, Response);
|
||||||
break;
|
break;
|
||||||
case FileDispositionInformation:
|
case FileDispositionInformation:
|
||||||
Result = FspFsvolSetDispositionInformation(FileObject, Buffer, Length, Request, Response);
|
Result = FspFsvolSetDispositionInformation(FileObject, Buffer, Length, Request, Response);
|
||||||
break;
|
break;
|
||||||
case FileEndOfFileInformation:
|
case FileEndOfFileInformation:
|
||||||
FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.SetInformation.FileInfo);
|
|
||||||
Result = FspFsvolSetEndOfFileInformation(FileObject, Buffer, Length,
|
Result = FspFsvolSetEndOfFileInformation(FileObject, Buffer, Length,
|
||||||
IrpSp->Parameters.SetFile.AdvanceOnly, Request, Response);
|
IrpSp->Parameters.SetFile.AdvanceOnly, Request, Response);
|
||||||
break;
|
break;
|
||||||
|
@ -420,9 +420,9 @@ NTSTATUS SetBasicInfo(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
if (0 != CreationTime)
|
if (0 != CreationTime)
|
||||||
FileNode->FileInfo.CreationTime = CreationTime;
|
FileNode->FileInfo.CreationTime = CreationTime;
|
||||||
if (0 != LastAccessTime)
|
if (0 != LastAccessTime)
|
||||||
FileNode->FileInfo.CreationTime = LastAccessTime;
|
FileNode->FileInfo.LastAccessTime = LastAccessTime;
|
||||||
if (0 != LastWriteTime)
|
if (0 != LastWriteTime)
|
||||||
FileNode->FileInfo.CreationTime = LastWriteTime;
|
FileNode->FileInfo.LastWriteTime = LastWriteTime;
|
||||||
|
|
||||||
*FileInfo = FileNode->FileInfo;
|
*FileInfo = FileNode->FileInfo;
|
||||||
|
|
||||||
@ -437,15 +437,18 @@ NTSTATUS SetAllocationSize(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
||||||
PVOID FileData;
|
PVOID FileData;
|
||||||
|
|
||||||
FileData = realloc(FileNode->FileData, AllocationSize);
|
if (FileNode->FileInfo.AllocationSize != AllocationSize)
|
||||||
if (0 == FileData)
|
{
|
||||||
return STATUS_INSUFFICIENT_RESOURCES;
|
FileData = realloc(FileNode->FileData, AllocationSize);
|
||||||
|
if (0 == FileData)
|
||||||
|
return STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|
||||||
FileNode->FileData = FileData;
|
FileNode->FileData = FileData;
|
||||||
|
|
||||||
FileNode->FileInfo.AllocationSize = AllocationSize;
|
FileNode->FileInfo.AllocationSize = AllocationSize;
|
||||||
if (FileNode->FileInfo.FileSize > AllocationSize)
|
if (FileNode->FileInfo.FileSize > AllocationSize)
|
||||||
FileNode->FileInfo.FileSize = AllocationSize;
|
FileNode->FileInfo.FileSize = AllocationSize;
|
||||||
|
}
|
||||||
|
|
||||||
*FileInfo = FileNode->FileInfo;
|
*FileInfo = FileNode->FileInfo;
|
||||||
|
|
||||||
@ -459,18 +462,21 @@ NTSTATUS SetFileSize(FSP_FILE_SYSTEM *FileSystem,
|
|||||||
{
|
{
|
||||||
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
|
||||||
|
|
||||||
if (FileNode->FileInfo.AllocationSize < FileSize)
|
if (FileNode->FileInfo.FileSize != FileSize)
|
||||||
{
|
{
|
||||||
UINT64 AllocationUnit = MEMFS_SECTOR_SIZE * MEMFS_SECTORS_PER_ALLOCATION_UNIT;
|
if (FileNode->FileInfo.AllocationSize < FileSize)
|
||||||
UINT64 AllocationSize = (FileSize + AllocationUnit - 1) / AllocationUnit * AllocationUnit;
|
{
|
||||||
|
UINT64 AllocationUnit = MEMFS_SECTOR_SIZE * MEMFS_SECTORS_PER_ALLOCATION_UNIT;
|
||||||
|
UINT64 AllocationSize = (FileSize + AllocationUnit - 1) / AllocationUnit * AllocationUnit;
|
||||||
|
|
||||||
NTSTATUS Result = SetAllocationSize(FileSystem, Request, FileNode, AllocationSize, FileInfo);
|
NTSTATUS Result = SetAllocationSize(FileSystem, Request, FileNode, AllocationSize, FileInfo);
|
||||||
if (!NT_SUCCESS(Result))
|
if (!NT_SUCCESS(Result))
|
||||||
return Result;
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
FileNode->FileInfo.FileSize = FileSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
FileNode->FileInfo.FileSize = FileSize;
|
|
||||||
|
|
||||||
*FileInfo = FileNode->FileInfo;
|
*FileInfo = FileNode->FileInfo;
|
||||||
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user