sys,dll: Flush now takes FileInfo parameter

This commit is contained in:
Bill Zissimopoulos 2016-12-26 13:59:53 -08:00
parent bec91873fe
commit c8206751d2
7 changed files with 64 additions and 12 deletions

View File

@ -422,6 +422,10 @@ typedef struct
FSP_FSCTL_FILE_INFO FileInfo; /* valid: File{Allocation,Basic,EndOfFile}Information */ FSP_FSCTL_FILE_INFO FileInfo; /* valid: File{Allocation,Basic,EndOfFile}Information */
} SetInformation; } SetInformation;
struct struct
{
FSP_FSCTL_FILE_INFO FileInfo; /* valid when flushing file (not volume) */
} FlushBuffers;
struct
{ {
FSP_FSCTL_VOLUME_INFO VolumeInfo; FSP_FSCTL_VOLUME_INFO VolumeInfo;
} QueryVolumeInformation; } QueryVolumeInformation;

View File

@ -433,11 +433,16 @@ typedef struct _FSP_FILE_SYSTEM_INTERFACE
* The file system on which this request is posted. * The file system on which this request is posted.
* @param FileContext * @param FileContext
* The file context of the file to be flushed. When NULL the whole volume is being flushed. * The file context of the file to be flushed. When NULL the whole volume is being flushed.
* @param FileInfo [out]
* Pointer to a structure that will receive the file information on successful return
* from this call. This information includes file attributes, file times, etc. Used when
* flushing file (not volume).
* @return * @return
* STATUS_SUCCESS or error code. * STATUS_SUCCESS or error code.
*/ */
NTSTATUS (*Flush)(FSP_FILE_SYSTEM *FileSystem, NTSTATUS (*Flush)(FSP_FILE_SYSTEM *FileSystem,
PVOID FileContext); PVOID FileContext,
FSP_FSCTL_FILE_INFO *FileInfo);
/** /**
* Get file or directory information. * Get file or directory information.
* *

View File

@ -961,11 +961,21 @@ FSP_API NTSTATUS FspFileSystemOpWrite(FSP_FILE_SYSTEM *FileSystem,
FSP_API NTSTATUS FspFileSystemOpFlushBuffers(FSP_FILE_SYSTEM *FileSystem, FSP_API NTSTATUS FspFileSystemOpFlushBuffers(FSP_FILE_SYSTEM *FileSystem,
FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response) FSP_FSCTL_TRANSACT_REQ *Request, FSP_FSCTL_TRANSACT_RSP *Response)
{ {
if (0 == FileSystem->Interface->Flush) NTSTATUS Result;
return STATUS_SUCCESS; /* liar! */ FSP_FSCTL_FILE_INFO FileInfo;
return FileSystem->Interface->Flush(FileSystem, memset(&FileInfo, 0, sizeof FileInfo);
(PVOID)ValOfFileContext(Request->Req.FlushBuffers)); if (0 == FileSystem->Interface->Flush)
Result = FileSystem->Interface->GetFileInfo(FileSystem,
(PVOID)ValOfFileContext(Request->Req.FlushBuffers), &FileInfo);
else
Result = FileSystem->Interface->Flush(FileSystem,
(PVOID)ValOfFileContext(Request->Req.FlushBuffers), &FileInfo);
if (!NT_SUCCESS(Result))
return Result;
memcpy(&Response->Rsp.FlushBuffers.FileInfo, &FileInfo, sizeof FileInfo);
return STATUS_SUCCESS;
} }
FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem, FSP_API NTSTATUS FspFileSystemOpQueryInformation(FSP_FILE_SYSTEM *FileSystem,

View File

@ -1215,11 +1215,14 @@ success:
} }
static NTSTATUS fsp_fuse_intf_Flush(FSP_FILE_SYSTEM *FileSystem, static NTSTATUS fsp_fuse_intf_Flush(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode) PVOID FileNode,
FSP_FSCTL_FILE_INFO *FileInfo)
{ {
struct fuse *f = FileSystem->UserContext; struct fuse *f = FileSystem->UserContext;
struct fsp_fuse_file_desc *filedesc = FileNode; struct fsp_fuse_file_desc *filedesc = FileNode;
UINT32 Uid, Gid, Mode;
struct fuse_file_info fi; struct fuse_file_info fi;
FSP_FSCTL_FILE_INFO FileInfoBuf;
int err; int err;
NTSTATUS Result; NTSTATUS Result;
@ -1249,8 +1252,17 @@ static NTSTATUS fsp_fuse_intf_Flush(FSP_FILE_SYSTEM *FileSystem,
Result = fsp_fuse_ntstatus_from_errno(f->env, err); Result = fsp_fuse_ntstatus_from_errno(f->env, err);
} }
} }
if (!NT_SUCCESS(Result))
return Result; return Result;
Result = fsp_fuse_intf_GetFileInfoEx(FileSystem, filedesc->PosixPath, &fi,
&Uid, &Gid, &Mode, &FileInfoBuf);
if (!NT_SUCCESS(Result))
return Result;
memcpy(FileInfo, &FileInfoBuf, sizeof FileInfoBuf);
return STATUS_SUCCESS;
} }
static NTSTATUS fsp_fuse_intf_GetFileInfo(FSP_FILE_SYSTEM *FileSystem, static NTSTATUS fsp_fuse_intf_GetFileInfo(FSP_FILE_SYSTEM *FileSystem,

View File

@ -160,7 +160,7 @@ NTSTATUS FspFsvolFlushBuffersComplete(
if (!FspFileNodeIsValid(FileNode) || FileNode->IsRootDirectory) if (!FspFileNodeIsValid(FileNode) || FileNode->IsRootDirectory)
; ;
else else
SetFlag(FileObject->Flags, FO_FILE_MODIFIED); FspFileNodeSetFileInfo(FileNode, FileObject, &Response->Rsp.FlushBuffers.FileInfo, TRUE);
Result = STATUS_SUCCESS; Result = STATUS_SUCCESS;
} }

View File

@ -369,8 +369,8 @@ call :__ifstest %1 /d %2 /g VolumeInformation /z /v
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1 if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
rem call :__ifstest %1 /d %2 /g FileInformation /z /v rem call :__ifstest %1 /d %2 /g FileInformation /z /v
rem if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1 rem if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
rem call :__ifstest %1 /d %2 /g DirectoryInformation /z /v call :__ifstest %1 /d %2 /g DirectoryInformation /z /v
rem if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1 if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
call :__ifstest %1 /d %2 /g FileLocking /z /v call :__ifstest %1 /d %2 /g FileLocking /z /v
if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1 if !ERRORLEVEL! neq 0 set IfsTestMemfsExit=1
rem call :__ifstest %1 /d %2 /g OpLocks /z /v rem call :__ifstest %1 /d %2 /g OpLocks /z /v

View File

@ -1110,10 +1110,31 @@ static NTSTATUS Write(FSP_FILE_SYSTEM *FileSystem,
} }
NTSTATUS Flush(FSP_FILE_SYSTEM *FileSystem, NTSTATUS Flush(FSP_FILE_SYSTEM *FileSystem,
PVOID FileNode0) PVOID FileNode0,
FSP_FSCTL_FILE_INFO *FileInfo)
{ {
MEMFS_FILE_NODE *FileNode = (MEMFS_FILE_NODE *)FileNode0;
/* nothing to flush, since we do not cache anything */ /* nothing to flush, since we do not cache anything */
if (0 != FileNode)
{
#if 0
#if defined(MEMFS_NAMED_STREAMS)
if (0 != FileNode->MainFileNode)
FileNode->MainFileNode->FileInfo.LastAccessTime =
FileNode->MainFileNode->FileInfo.LastWriteTime =
FileNode->MainFileNode->FileInfo.ChangeTime = MemfsGetSystemTime();
else
#endif
FileNode->FileInfo.LastAccessTime =
FileNode->FileInfo.LastWriteTime =
FileNode->FileInfo.ChangeTime = MemfsGetSystemTime();
#endif
MemfsFileNodeGetFileInfo(FileNode, FileInfo);
}
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }