Browse Source

CreateFile related logging improvements

Tal Aloni 8 years ago
parent
commit
12aa96d588

+ 3 - 2
SMBLibrary/NTFileStore/Adapter/NTFileSystemAdapter.cs

@@ -258,7 +258,7 @@ namespace SMBLibrary
             bool disableBuffering = (openOptions & CreateOptions.FILE_NO_INTERMEDIATE_BUFFERING) > 0;
             bool buffered = (openOptions & CreateOptions.FILE_SEQUENTIAL_ONLY) > 0 && !disableBuffering && !openReparsePoint;
             FileShare fileShare = NTFileStoreHelper.ToFileShare(shareAccess);
-            Log(Severity.Information, "OpenFileStream: Opening '{0}', Access={1}, Share={2}, Buffered={3}", path, fileAccess, fileShare, buffered);
+            string fileShareString = fileShare.ToString().Replace(", ", "|");
             try
             {
                 stream = m_fileSystem.OpenFile(path, FileMode.Open, fileAccess, fileShare);
@@ -266,10 +266,11 @@ namespace SMBLibrary
             catch (Exception ex)
             {
                 NTStatus status = ToNTStatus(ex);
-                Log(Severity.Verbose, "OpenFile: Cannot open '{0}'. {1}.", path, status);
+                Log(Severity.Verbose, "OpenFile: Cannot open '{0}', Access={1}, Share={2}. NTStatus: {3}.", path, fileAccess, fileShareString, status);
                 return status;
             }
 
+            Log(Severity.Information, "OpenFileStream: Opened '{0}', Access={1}, Share={2}, Buffered={3}", path, fileAccess, fileShareString, buffered);
             if (buffered)
             {
                 stream = new PrefetchedStream(stream);

+ 1 - 0
SMBLibrary/Server/SMB1/NTCreateHelper.cs

@@ -42,6 +42,7 @@ namespace SMBLibrary.Server.SMB1
                 return new ErrorResponse(request.CommandName);
             }
 
+            state.LogToServer(Severity.Verbose, "Create: Opened '{0}{1}'.", share.Name, path);
             ushort? fileID = session.AddOpenFile(header.TID, path, handle);
             if (!fileID.HasValue)
             {

+ 1 - 0
SMBLibrary/Server/SMB1/OpenAndXHelper.cs

@@ -58,6 +58,7 @@ namespace SMBLibrary.Server.SMB1
                 return new ErrorResponse(request.CommandName);
             }
 
+            state.LogToServer(Severity.Verbose, "OpenAndX: Opened '{0}{1}'.", share.Name, path);
             ushort? fileID = session.AddOpenFile(header.TID, path, handle);
             if (!fileID.HasValue)
             {

+ 1 - 0
SMBLibrary/Server/SMB2/CreateHelper.cs

@@ -42,6 +42,7 @@ namespace SMBLibrary.Server.SMB2
                 return new ErrorResponse(request.CommandName, createStatus);
             }
 
+            state.LogToServer(Severity.Verbose, "Create: Opened '{0}{1}'.", share.Name, path);
             FileID? fileID = session.AddOpenFile(request.Header.TreeID, path, handle);
             if (fileID == null)
             {