From b2e677a3d35b62ea78f5ba5c97b260f1f58c9007 Mon Sep 17 00:00:00 2001 From: Bill Zissimopoulos Date: Tue, 6 Apr 2021 13:41:35 -0700 Subject: [PATCH] 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 --- src/sys/fileinfo.c | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/src/sys/fileinfo.c b/src/sys/fileinfo.c index 4f210d14..1061a3fb 100644 --- a/src/sys/fileinfo.c +++ b/src/sys/fileinfo.c @@ -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 {