sys: FspFsvolSetBasicInformation: issue #362

According to the FILE_BASIC_INFORMATION doc a file system should not update a file timestamp when it receives a value of -1 in the corresponding time field.

This commit converts a -1 timestamp to a 0 timestamp; this directs a WinFsp file system not to update the corresponding file timestamp.

This commit fixes issue #362
This commit is contained in:
Bill Zissimopoulos 2021-04-06 13:41:35 -07:00
parent 9d76495340
commit b2e677a3d3
No known key found for this signature in database
GPG Key ID: 3D4F95D52C7B3EA3

View File

@ -1288,10 +1288,31 @@ static NTSTATUS FspFsvolSetBasicInformation(PFILE_OBJECT FileObject,
}
Request->Req.SetInformation.Info.Basic.FileAttributes = FileAttributes;
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;
Request->Req.SetInformation.Info.Basic.ChangeTime = Info->ChangeTime.QuadPart;
/*
* From FILE_BASIC_INFORMATION (https://tinyurl.com/hwex4bd9):
*
* The file system updates the values of the LastAccessTime,
* LastWriteTime, and ChangeTime members as appropriate after an I/O
* operation is performed on a file. A driver or application can
* request that the file system not update one or more of these
* members for I/O operations that are performed on the caller's file
* handle by setting the appropriate members to -1. The caller can set
* one, all, or any other combination of these three members to -1.
* Only the members that are set to -1 will be unaffected by I/O
* operations on the file handle; the other members will be updated as
* appropriate.
*
* GitHub issue #362
*/
Request->Req.SetInformation.Info.Basic.CreationTime =
-1 != Info->CreationTime.QuadPart ? Info->CreationTime.QuadPart : 0;
Request->Req.SetInformation.Info.Basic.LastAccessTime =
-1 != Info->LastAccessTime.QuadPart ? Info->LastAccessTime.QuadPart : 0;
Request->Req.SetInformation.Info.Basic.LastWriteTime =
-1 != Info->LastWriteTime.QuadPart ? Info->LastWriteTime.QuadPart : 0;
Request->Req.SetInformation.Info.Basic.ChangeTime =
-1 != Info->ChangeTime.QuadPart ? Info->ChangeTime.QuadPart : 0;
}
else
{