Better handling of FILE_OPEN_REPARSE_POINT flag

This commit is contained in:
Tal Aloni 2016-12-27 09:51:13 +02:00
parent 2da05e979b
commit 6cb61ca63e

View file

@ -246,14 +246,18 @@ namespace SMBLibrary.Server
} }
Stream stream; Stream stream;
if ((request.CreateOptions & CreateOptions.FILE_OPEN_REPARSE_POINT) > 0 || fileAccess == (FileAccess)0 || entry.IsDirectory) if (fileAccess == (FileAccess)0 || entry.IsDirectory)
{ {
// FILE_OPEN_REPARSE_POINT is a hint that the caller does not intend to actually read the file
stream = null; stream = null;
} }
else else
{ {
bool buffered = (request.CreateOptions & CreateOptions.FILE_SEQUENTIAL_ONLY) > 0 && (request.CreateOptions & CreateOptions.FILE_NO_INTERMEDIATE_BUFFERING) == 0; // When FILE_OPEN_REPARSE_POINT is specified, the operation should continue normally if the file is not a reparse point.
// FILE_OPEN_REPARSE_POINT is a hint that the caller does not intend to actually read the file, with the exception
// of a file copy operation (where the caller will attempt to simply copy the reparse point).
bool openReparsePoint = (request.CreateOptions & CreateOptions.FILE_OPEN_REPARSE_POINT) > 0;
bool disableBuffering = (request.CreateOptions & CreateOptions.FILE_NO_INTERMEDIATE_BUFFERING) > 0;
bool buffered = (request.CreateOptions & CreateOptions.FILE_SEQUENTIAL_ONLY) > 0 && !disableBuffering && !openReparsePoint;
System.Diagnostics.Debug.Print("[{0}] NTCreate: Opening '{1}', Access={2}, Share={3}, Buffered={4}", DateTime.Now.ToString("HH:mm:ss:ffff"), path, fileAccess, fileShare, buffered); System.Diagnostics.Debug.Print("[{0}] NTCreate: Opening '{1}', Access={2}, Share={3}, Buffered={4}", DateTime.Now.ToString("HH:mm:ss:ffff"), path, fileAccess, fileShare, buffered);
try try
{ {