From 4802bf3e16ee4608d0d007e9e4a460cd0cd63769 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Fri, 3 Feb 2017 16:50:36 -0500 Subject: [PATCH] Remote debug: Use the IFileStore interface to force the file executable Instead of calling "chmod +x" by hand, use IFileStore.putInfo to set the file attributes. Since we already use the IFileStore API to copy the file, it makes sense (and it's cleaner) to use it to set the executable attribute as well. In most cases, it wouldn't be needed to make the file executable, since it should already be on the host filesystem and IFileStore.copy transfers the attributes. However, it's still good to force it executable in case it's not already for some reason. Change-Id: I4c86e36265962781d4541aaceeb40b502248f674 Signed-off-by: Simon Marchi --- .../cdt/launch/remote/RemoteHelper.java | 31 +++++-------------- 1 file changed, 8 insertions(+), 23 deletions(-) diff --git a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java index 7b991d07410..1bd29ea39e6 100644 --- a/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java +++ b/cross/org.eclipse.cdt.launch.remote/src/org/eclipse/cdt/launch/remote/RemoteHelper.java @@ -18,12 +18,12 @@ import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.TimeUnit; import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; import org.eclipse.cdt.internal.launch.remote.Activator; import org.eclipse.cdt.internal.launch.remote.Messages; import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileInfo; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.IFileSystem; import org.eclipse.core.runtime.CoreException; @@ -115,32 +115,17 @@ public class RemoteHelper { return; } + /* Copy the file to the remote file system. */ localFile.copy(remoteFile, EFS.OVERWRITE, subMonitor.split(95)); - // Need to change the permissions to match the original file - // permissions because of a bug in upload - Process p = remoteShellExec( - config, - "", "chmod", "+x " + spaceEscapify(remoteExePath), subMonitor.split(5)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + /* Force the file to executable. */ + IFileInfo remoteFileInfo = remoteFile.fetchInfo(); - // Wait if necessary for the permission change - try { - int timeOut = 10; - boolean exited = p.waitFor(timeOut, TimeUnit.SECONDS); + remoteFileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE, true); + remoteFileInfo.setAttribute(EFS.ATTRIBUTE_GROUP_EXECUTE, true); + remoteFileInfo.setAttribute(EFS.ATTRIBUTE_OTHER_EXECUTE, true); - if (!exited) { - Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, - "Failed to change file permissions in the remote system, path: " + remoteExePath, //$NON-NLS-1$ - null); - throw new CoreException(status); - } - } catch (InterruptedException e) { - Status status = new Status(IStatus.ERROR, Activator.PLUGIN_ID, IStatus.ERROR, - "Interrupted while changing file permissions in the remote system, path: " //$NON-NLS-1$ - + remoteExePath, - e); - throw new CoreException(status); - } + remoteFile.putInfo(remoteFileInfo, EFS.SET_ATTRIBUTES, subMonitor.split(5)); } catch (CoreException e) { abort(Messages.RemoteRunLaunchDelegate_6, e, ICDTLaunchConfigurationConstants.ERR_INTERNAL_ERROR);