Skip to content

Commit

Permalink
Mount: Remove tracing on TryAttach
Browse files Browse the repository at this point in the history
Allow the caller to determine how to handle the error.  This is because a command line error may fail due to permissions and be retried successfully by the service.
  • Loading branch information
jeschu1 committed Oct 25, 2018
1 parent 9b2d5a8 commit f2c63e8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
7 changes: 2 additions & 5 deletions GVFS/GVFS.Platform.Windows/ProjFSFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ private enum ProjFSInboxStatus

public string DriverLogFolderName { get; } = ProjFSFilter.ServiceName;

public static bool TryAttach(ITracer tracer, string enlistmentRoot, out string errorMessage)
public static bool TryAttach(string enlistmentRoot, out string errorMessage)
{
errorMessage = null;
try
Expand All @@ -56,22 +56,19 @@ public static bool TryAttach(ITracer tracer, string enlistmentRoot, out string e
if (!NativeMethods.GetVolumePathName(enlistmentRoot, volumePathName, GVFSConstants.MaxPath))
{
errorMessage = "Could not get volume path name";
tracer.RelatedError($"{nameof(TryAttach)}:{errorMessage}");
return false;
}

uint result = NativeMethods.FilterAttach(DriverName, volumePathName.ToString(), null);
if (result != OkResult && result != NameCollisionErrorResult)
{
errorMessage = string.Format("Attaching the filter driver resulted in: {0}", result);
tracer.RelatedError(errorMessage);
return false;
}
}
catch (Exception e)
{
errorMessage = string.Format("Attaching the filter driver resulted in: {0}", e.Message);
tracer.RelatedError(errorMessage);
return false;
}

Expand Down Expand Up @@ -373,7 +370,7 @@ public bool IsReady(JsonTracer tracer, string enlistmentRoot, out string error)
return
IsServiceRunning(tracer) &&
IsNativeLibInstalled(tracer, new PhysicalFileSystem()) &&
TryAttach(tracer, enlistmentRoot, out error);
TryAttach(enlistmentRoot, out error);
}

private static bool IsInboxAndEnabled()
Expand Down
2 changes: 1 addition & 1 deletion GVFS/GVFS.Service/Handlers/EnableAndAttachProjFSHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void Run()

if (!string.IsNullOrEmpty(this.request.EnlistmentRoot))
{
if (!ProjFSFilter.TryAttach(this.tracer, this.request.EnlistmentRoot, out errorMessage))
if (!ProjFSFilter.TryAttach(this.request.EnlistmentRoot, out errorMessage))
{
state = NamedPipeMessages.CompletionState.Failure;
this.tracer.RelatedError("Unable to attach filter to volume. Enlistment root: {0} \nError: {1} ", this.request.EnlistmentRoot, errorMessage);
Expand Down
9 changes: 8 additions & 1 deletion GVFS/GVFS/CommandLine/MountVerb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,14 @@ protected override void Execute(GVFSEnlistment enlistment)

if (!GVFSPlatform.Instance.KernelDriver.IsReady(tracer, enlistment.EnlistmentRoot, out errorMessage))
{
tracer.RelatedInfo($"{nameof(MountVerb)}.{nameof(this.Execute)}: Enabling and attaching ProjFS through service");
tracer.RelatedEvent(
EventLevel.Informational,
$"{nameof(MountVerb)}_{nameof(this.Execute)}_EnablingKernelDriverViaService",
new EventMetadata
{
{ "KernelDriver.IsReady_Error", errorMessage },
{ TracingConstants.MessageKey.InfoMessage, "Service will retry" }
});

if (!this.ShowStatusWhileRunning(
() => { return this.TryEnableAndAttachPrjFltThroughService(enlistment.EnlistmentRoot, out errorMessage); },
Expand Down

0 comments on commit f2c63e8

Please sign in to comment.