Ejemplo n.º 1
0
 private void WriteToClient(NamedPipeMessages.AttachGvFltRequest.Response response)
 {
     NamedPipeMessages.Message message = response.ToMessage();
     if (!this.connection.TrySendResponse(message))
     {
         this.tracer.RelatedError("Failed to send line to client: {0}", message);
     }
 }
Ejemplo n.º 2
0
        private bool AttachGvFltThroughService(GVFSEnlistment enlistment, out string errorMessage)
        {
            errorMessage = string.Empty;

            NamedPipeMessages.AttachGvFltRequest request = new NamedPipeMessages.AttachGvFltRequest();
            request.EnlistmentRoot = enlistment.EnlistmentRoot;

            using (NamedPipeClient client = new NamedPipeClient(this.ServicePipeName))
            {
                if (!client.Connect())
                {
                    errorMessage = "Unable to mount because GVFS.Service is not responding. " + GVFSVerb.StartServiceInstructions;
                    return(false);
                }

                try
                {
                    client.SendRequest(request.ToMessage());
                    NamedPipeMessages.Message response = client.ReadResponse();
                    if (response.Header == NamedPipeMessages.AttachGvFltRequest.Response.Header)
                    {
                        NamedPipeMessages.AttachGvFltRequest.Response message = NamedPipeMessages.AttachGvFltRequest.Response.FromMessage(response);

                        if (!string.IsNullOrEmpty(message.ErrorMessage))
                        {
                            errorMessage = message.ErrorMessage;
                            return(false);
                        }

                        if (message.State != NamedPipeMessages.CompletionState.Success)
                        {
                            errorMessage = "Failed to attach GvFlt to volume.";
                            return(false);
                        }
                        else
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        errorMessage = string.Format("GVFS.Service responded with unexpected message: {0}", response);
                        return(false);
                    }
                }
                catch (BrokenPipeException e)
                {
                    errorMessage = "Unable to communicate with GVFS.Service: " + e.ToString();
                    return(false);
                }
            }
        }
Ejemplo n.º 3
0
        public void Run()
        {
            string errorMessage;

            NamedPipeMessages.CompletionState state = NamedPipeMessages.CompletionState.Success;
            if (!GvFltFilter.TryAttach(this.tracer, 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);
            }

            NamedPipeMessages.AttachGvFltRequest.Response response = new NamedPipeMessages.AttachGvFltRequest.Response();

            response.State        = state;
            response.ErrorMessage = errorMessage;

            this.WriteToClient(response.ToMessage(), this.connection, this.tracer);
        }